QtSerialPort, readyRead emitted multiple times
-
Hello,
I have been reading people dealing with this issue, but still trying to get my head around it.
I am running the Qt example for reader async (no more than that, except for that I am not stopping it once the read is done as this is what I want in my final app). Despite I expect one message to be read from serial port, I get the same message printed out multiple times.
How can you deal with the problem of emitting readyread more than once?
THanks in advance for your help
-
Are you sure the sender doesn't send data continuously?
-
Have a look at
void ChatClient::onReadyRead()
of this wiki page. It usesQTcpSocket
but the explanation is valid forQSerialPort
too -
readyread can trigger on any number of received characters, including (especially) an incomplete message. you are reading a stream. Just because you send a discrete message doesnt mean its received and parsed as a discrete message.