if USB serial cable is unplugged, there is a serialPortError Problem !
i use ;
connect(mySerialPort, SIGNAL(error(QSerialPort::SerialPortError)), this,
SLOT(handleError(QSerialPort::SerialPortError)));
...
void MyClass::handleError(QSerialPort::SerialPortError error)
{
if (error == QSerialPort::ResourceError) {
QMessageBox::critical(this, tr("Critical Error"), serial->errorString());
closeSerialPort();
}
}
BUT
if USB serial cable is unplugged, my program wants to stay in " if (error == QSerialPort::ResourceError) {...} " loop so always give me error message despite close the error messages again and again.
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
The message box uses a nested event loop to process events.
Since you have not closed the port yet you are just getting more errors, resulting in entering the same slots over and over again.
Cheers,
_
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
i got it but i used closeSerialPort() function after message to close opened port ... what can i do more to fix it ?
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Quote:
Originally Posted by
hazel
i got it but i used closeSerialPort() function after message to close opened port ... what can i do more to fix it ?
If you close it after the message, what do you think happens if an error occurs while you are showing the message?
Cheers,
_
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Added after 5 minutes:
Quote:
Originally Posted by
anda_skoa
If you close it after the message, what do you think happens if an error occurs while you are showing the message?
Cheers,
_
you r right ;-) but still i dont know what can i do for that ... i used all cases after your message .
Note : i'm beginner :)
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Have you tried closing before showing the message box?
Cheers,
_
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Quote:
Originally Posted by
anda_skoa
Have you tried closing before showing the message box?
Cheers,
_
Yep, because of that program has unexpectedly finished.
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Maybe you invalidate "serial" inside closeSerialPort.
If so you need to get the error string before calling closeSerialPort.
Cheers,
_
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
i did , QT terminal example is like that but not work ... thank you , i will try to other way if i find ;-)
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
Heyy... i just want to share ; actually this problem about Linux operating system ( i m using ROSA ),
Ä° dont have same problem in Windows so use different way in linux ;-)
Re: if USB serial cable is unplugged, there is a serialPortError Problem !
https://bugreports.qt.io/browse/QTBUG-50052 ?
now it works for you after this patch? have you tested it now (for 5.6)?