Reputation: 61
I am using QSerialPort to send an receive data in Qt5.5 (windows) and everything works as expected except in one case, when the data sent back contains 0x11. I see this is a special ascii value but would like to read it in as a raw byte. My setup is as follows:
setBaudRate(QSerialPort::Baud115200);
setDataBits(QSerialPort::Data8);
setStopBits(QSerialPort::OneStop);
setFlowControl(QSerialPort::SoftwareControl);
setParity(QSerialPort::NoParity);
Later...
open(QIODevice::ReadWrite);
My reading in a slot connected to readyRead():
buffer_.append(readAll());
where buffer_ is a QByteArray.
An example packet would be:
0xBF 0x00 0x00 0x00 0x00 0x04 0x11 0x00 0x02 0x70
and the packet I would receive:
0xBF 0x00 0x00 0x00 0x00 0x04 0x00 0x02 0x70
Upvotes: 1
Views: 247
Reputation: 13130
0x11
and 0x13
are flow control bytes in Sofware Flow mode. This is why 0x11
was "dropped". Using NoFlowControl
means that you have to control flow by yourself. I.e. you can't write to much data in short time as you will lose it.
Upvotes: 0
Reputation: 61
As per Kamil Klimek I changed to no flow control and it works.
setFlowControl(QSerialPort::NoFlowControl);
Upvotes: 1