Looking for a signal in QSerialPort class that tells when the port gets disconnect
-
Hi,
I'm using QSerialPort class and would like to connect an event to a SIGNAL that tells me when the serial port is disconnected.
Is there a signal for that?
If there is no signal, how should I check this issue with out checking with timeout each x seconds if
@port->isOpen() == true@???
thanks.
-
-
bq. when I disconnected the serial cable
What do you mean about "disconnected the serial cable"?
If this means about RS232/TTL side, then it is impossible to know that cable is "disconnected", since RS232 interface does not provide this features.
If this means about disconnecting of USB/Serial converter from USB port, then can be use QSerialPort::ResourceError (please read documentation). But this signal will be emmited only if the port was open (but even it doesn't guarantee it, depends on HW driver). Perhaps in the future we will refuse ResourceError signal.
A common solution (for USB/Serial or PCI/Serial) devices - it is watching for system event about connecting/disconnecting of device (using udev and so on).
You can look how this works from:
https://code.google.com/p/qextserialport/source/browse/src/qextserialenumerator.h
or