QSerialPort: problem with waitForReadyRead()
-
@kuzulis said in QSerialPort: problem with waitForReadyRead():
What is OS, and what is Qt version?
OS: Windows 10
Qt Version: 5.13.1
Building: MinGW 32-bit@oBOXPOH
I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1see this bugreport
https://bugreports.qt.io/browse/QTBUG-78086 -
@oBOXPOH
I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1see this bugreport
https://bugreports.qt.io/browse/QTBUG-78086@J-Hilk said in QSerialPort: problem with waitForReadyRead():
@oBOXPOH
I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1see this bugreport
https://bugreports.qt.io/browse/QTBUG-78086Tried Qt 5.9.8.
In this case waitForReadyRead() always returns false with accepted write command.
-
@oBOXPOH
Like I & @J-Hilk have said, suggest you at least try it withreadyRead
signal instead of waits and see if that makes the difference?@JonB said in QSerialPort: problem with waitForReadyRead():
@oBOXPOH
Like I & @J-Hilk have said, suggest you at least try it withreadyRead
signal instead of waits and see if that makes the difference?I tried next (all is inside the class):
connect(deviceControl_SerialPort, &QSerialPort::readyRead, this, &Class::readData_slot);
void Class::readData_slot() { qDebug() << "Ready Read" << endl; deviceControl_readData.append(deviceControl_SerialPort->readAll()); }
In this case I can't reach readData_slot() method.
Then I tried next:
connect(deviceControl_SerialPort, &QSerialPort::errorOccurred, this, &Class::serialPortError_slot);
void Class::serialPortError_slot(QSerialPort::SerialPortError error) { qDebug() << error << endl; }
and got some error (see log below):
WRITTEN 1 READING... QSerialPort::TimeoutError WRITTEN 2 READING... QSerialPort::TimeoutError WRITTEN 3 QSerialPort::TimeoutError I AM NOT READY! Ready Read Ready Read
and, by the way, message for readyRead signal. Strangely, that I got it only after 2 real readings...
-
@JonB said in QSerialPort: problem with waitForReadyRead():
@oBOXPOH
Like I & @J-Hilk have said, suggest you at least try it withreadyRead
signal instead of waits and see if that makes the difference?I tried next (all is inside the class):
connect(deviceControl_SerialPort, &QSerialPort::readyRead, this, &Class::readData_slot);
void Class::readData_slot() { qDebug() << "Ready Read" << endl; deviceControl_readData.append(deviceControl_SerialPort->readAll()); }
In this case I can't reach readData_slot() method.
Then I tried next:
connect(deviceControl_SerialPort, &QSerialPort::errorOccurred, this, &Class::serialPortError_slot);
void Class::serialPortError_slot(QSerialPort::SerialPortError error) { qDebug() << error << endl; }
and got some error (see log below):
WRITTEN 1 READING... QSerialPort::TimeoutError WRITTEN 2 READING... QSerialPort::TimeoutError WRITTEN 3 QSerialPort::TimeoutError I AM NOT READY! Ready Read Ready Read
and, by the way, message for readyRead signal. Strangely, that I got it only after 2 real readings...
Hi @oBOXPOH,
Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.
You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html
Regards
-
Hi @oBOXPOH,
Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.
You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html
Regards
@aha_1980 said in QSerialPort: problem with waitForReadyRead():
Hi @oBOXPOH,
Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.
You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html
Regards
Terminal Example also works badly -> https://forum.qt.io/topic/108848/terminal-example-for-qserialport-doesn-t-work-correctly
-
@aha_1980 said in QSerialPort: problem with waitForReadyRead():
Hi @oBOXPOH,
Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.
You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html
Regards
Terminal Example also works badly -> https://forum.qt.io/topic/108848/terminal-example-for-qserialport-doesn-t-work-correctly
@oBOXPOH said in QSerialPort: problem with waitForReadyRead():
@aha_1980 said in QSerialPort: problem with waitForReadyRead():
Hi @oBOXPOH,
Qt is an event-driven framework. By using endless loops, wait routines you create problems if you don't know what you are exactly doing.
You should use QSerialPort with signals and slots. An example is shown here: https://doc.qt.io/qt-5/qtserialport-terminal-example.html
Regards
Terminal Example also works badly -> https://forum.qt.io/topic/108848/terminal-example-for-qserialport-doesn-t-work-correctly
Solution is to install 5.13.2 or more version of Qt.
-
@oBOXPOH Hello i am having the same exact problem with QT, i don't receive any output by triggering the readyread signal or by using the return value of waitForReadyRead(), is it really issue related to QT version??
=> I do have 5.12 version of QT, i want to make sure that that is the problem before deciding to do an upgrade..Thank you in advance for your reply!
-
@oBOXPOH
I would suggest to use a different Qt version QSerialPort has some serious issues in 5.13.1see this bugreport
https://bugreports.qt.io/browse/QTBUG-78086 -
iirc 5.12 should work fine, only 5.13 had the issues
-
@J-Hilk Thank you for your reply, i had upgraded my QT and i still had the same issue, when i send one byte i don't receive any feedback from my device(readyRead is not triggered), it has to be more than one byte in order to receive something. do you please have any idea why is this happening?
-
@J-Hilk Thank you for your reply, i had upgraded my QT and i still had the same issue, when i send one byte i don't receive any feedback from my device(readyRead is not triggered), it has to be more than one byte in order to receive something. do you please have any idea why is this happening?
@DiaaQTdev
Can you show your code?