PDA

View Full Version : serial port communications- functions



kulsekarr
21st October 2013, 10:43
Hi,
i am reading data's from serial port using readyread function,using QSerialDevice and if serial port doesn't sends any data, is there any function to handle it? And if the data's are sent continuously and in-between if it is disconnected how to handle it. kindly do suggest me with some solutions.

Thanks in advance

kuzulis
21st October 2013, 12:30
1. Instead of old QSerialDevice use the QtSerialPort (http://qt-project.org/wiki/QtSerialPort)

2.


if serial port doesn't sends any data, is there any function to handle it?

Sorry? What do you mean?

3.

And if the data's are sent continuously and in-between if it is disconnected how to handle it.

What is mean by disconnected?

kulsekarr
21st October 2013, 12:45
Thankyou kuzulis. I am using Qt5.1.0 which has a inbuilt class QserialDevice.

I am having a battery enabled device which sends data in form a packet, through serial port.. if the battery gets drained i would not receive any data . how can it be notified and which function i can use?

using readyread() function i am reading all the data's form the port. and the packet information from the device doesn't send any data for notification of low battery.

Thanks..

ChrisW67
21st October 2013, 12:51
if the battery gets drained i would not receive any data . how can it be notified and which function i can use?
There is no magic therOtherEndHasGoneQuiet() signal. You can start or restart a long timer every time data is received. If the timer expires then the other end has stopped sending.


and the packet information from the device doesn't send any data for notification of low battery.

Then I guess you get no warning that transmission is going to cease. This has nothing to do with Qt though.

kuzulis
21st October 2013, 13:02
Yes, as say ChrisW67.

Also can be use the additional RTS and so on pinout signals in case your battery can provide it. Then in your application you can periodically read the state of this pinout and know if the battery will be empty (e.g. this pinout can be reset to low). In any case see the datasheet of your battery.