PDA

View Full Version : if USB serial cable is unplugged, there is a serialPortError Problem !



hazel
18th December 2015, 09:45
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.

anda_skoa
18th December 2015, 10:29
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,
_

hazel
18th December 2015, 11:44
i got it but i used closeSerialPort() function after message to close opened port ... what can i do more to fix it ?

anda_skoa
18th December 2015, 11:54
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,
_

hazel
18th December 2015, 12:30
Added after 5 minutes:


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 :)

anda_skoa
18th December 2015, 12:42
Have you tried closing before showing the message box?

Cheers,
_

hazel
18th December 2015, 12:56
Have you tried closing before showing the message box?

Cheers,
_

Yep, because of that program has unexpectedly finished.

anda_skoa
18th December 2015, 13:17
Maybe you invalidate "serial" inside closeSerialPort.
If so you need to get the error string before calling closeSerialPort.

Cheers,
_

hazel
18th December 2015, 13:40
i did , QT terminal example is like that but not work ... thank you , i will try to other way if i find ;-)

kuzulis
19th December 2015, 09:19
https://bugreports.qt.io/browse/QTBUG-50052

hazel
25th January 2016, 14:32
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 ;-)

kuzulis
26th January 2016, 11:47
https://bugreports.qt.io/browse/QTBUG-50052 ?

now it works for you after this patch? have you tested it now (for 5.6)?