if I unplug the device then also function QSerialPortInfo::availablePorts(); show serial port is avaiable. Is it other ways to find the devices is disconnected or not?
-
I am using Qt 5.6.3. Here I found some realated document https://bugreports.qt.io/browse/QTBUG-50052. Inside the Document, find the unconnected port with help of error but I could not generate the error because port open,close, read, write handle into separate thread. current thread, just check the device is connected or not. if device is connected then data will be trasfer manually from GUI or receive into GUI.
Device is not connected which is identify by comparing two list, already connected port and available port.
auto availablePorts = QSerialPortInfo::availablePorts();
if already connected port is not avaiable into avaiable port the device is disconnected and device show into GUI.
auto error = QSerialPort::SerialPortError();
qdebug() << "error" << error;here i am always getting QSerialPort::NoError.
How can I solve this issue? or how can i Use QserialPortinfo from another verison of QT?
-
I am using Qt 5.6.3. Here I found some realated document https://bugreports.qt.io/browse/QTBUG-50052. Inside the Document, find the unconnected port with help of error but I could not generate the error because port open,close, read, write handle into separate thread. current thread, just check the device is connected or not. if device is connected then data will be trasfer manually from GUI or receive into GUI.
Device is not connected which is identify by comparing two list, already connected port and available port.
auto availablePorts = QSerialPortInfo::availablePorts();
if already connected port is not avaiable into avaiable port the device is disconnected and device show into GUI.
auto error = QSerialPort::SerialPortError();
qdebug() << "error" << error;here i am always getting QSerialPort::NoError.
How can I solve this issue? or how can i Use QserialPortinfo from another verison of QT?
-
On Windows, if you try to unplug an already opened serial port, then the QSPI may show that this serial port is available within some time, or, until you do not close it. It is completelly OS-specific issue, as Andre already said before.
If you want to watch for a true serial port availability, then you need to implement own class-watcher, using WM_DEVICECHANGE on Windows, or, using udev's API on Linux (if you needs in).
PS: Also I recomment update your Qt to latest.