Is there any signal for port disconnect in qextserialport
-
Hi
I am using USB to serial port device which can be physically disconnected
when i open the port using qextserialport library and then disconnect the port physically, running exe hangs.
so is there any signal for port disconnect in qextserialport -
QextSerialPort has a similar signals into QextSerialEnumerator class:
- deviceDiscovered()
- deviceRemoved()
But I am not sure that they are implemented for all platforms.
Though, you can use other module "QtSerialPort":https://qt-project.org/doc/qt-5.1/qtserialport/qtserialport-module.html which has "QSerialPort::error()":https://qt-project.org/doc/qt-5.1/qtserialport/qserialport.html#error-prop signal with "ResourceError":https://qt-project.org/doc/qt-5.1/qtserialport/qserialport.html#SerialPortError-enum code. This signal will be emitted if to pull out already open device from system (e.g. pull USB cable).
The module "QtSerialPort":https://qt-project.org/doc/qt-5.1/qtserialport/qtserialport-module.html was introduced into Qt5.1 (by default), also you can build this module yourself for Qt4.8.x, see "Wiki":http://qt-project.org/wiki/QtSerialPort.
-
thanks for reply
i have tried deviceDiscovered() & deviceRemoved() but nothing worked
i will try Qtserialport module. -
bq. i will try Qtserialport module.
Yes, then please let know about results. If something doesn't work - that we will try to fix it quickly. :)
UPD: You can check it in "Simply Terminal" example (which is delivered with QtSerialPport). Just try to open device and pull an USB cable, then Terminal should display the messagebox with "ResourceError" error.
-
Thanks kuzulls
QtSerialPort works, it provides signals for all serial port errors so i can able to detect the USB port disconnect event.
but for this i have ported my code to QT5 then it worked
Thanks again...