Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QtSerialPort sending data
Hi and hello,
short problem. I try to send 3 commands with QtSerialPort to a device. If I send them in 3 different routines triggered by 3 buttons it works perfect. If I call these 3 routines from one additional routine it fails. The fourth routine includes the correct timing (sleep(2000)) on a windows system. A port sniffer shows the right commands, a break of 2000 ms from the first one to the second, but the third one comes together with the second one.
button1-click -> command1
button2-click -> command2
button3-click -> command3
the other way
button4-click -> command1 -> sleep(2000)->command2->sleep(2000)->command3
Why there is no break between command2 and command3 in the second way?
kuzulis last edited by
Please do not use sleep() call, because it is freeze event-loop.
Instead use QTimer with command interval 2000 msec to send.
But then I have to use signal - slot more...
My little problem I solved this way. Now I wait for the response from the first command in a signal - slot loop, and it helps
IMHO, if you're going to use Qt, then you really need to lose the idea that using signals and slots are bad or cumbersome or something to avoid having to use. They're a fundamental part of the tool kit.
I know. And now, with using these tools it loks pretty good. And it works! Thanks you.