Serial Port Data Loss
-
Hello, I am exchanging data with the CPU via serial port. The data coming from the CPU appears missing on my console screen. How can I fix this?
QByteArray dataPacket = serial->readAll();
This is how I read the incoming data packet.The value I want to display on the console screen: Main data coming via Serial Port "\x02\x00\xB0\x13\x0F\xFA\x02\xCE\x03"
but The value I see: "\x02\x00\xB0\x13\x0F" -
Hello, I am exchanging data with the CPU via serial port. The data coming from the CPU appears missing on my console screen. How can I fix this?
QByteArray dataPacket = serial->readAll();
This is how I read the incoming data packet.The value I want to display on the console screen: Main data coming via Serial Port "\x02\x00\xB0\x13\x0F\xFA\x02\xCE\x03"
but The value I see: "\x02\x00\xB0\x13\x0F"@Rumeysa_135 said in Serial Port Data Loss:
exchanging data with the CPU via serial port
CPU?!
"This is how I read the incoming data packet" - where and when do you do this? Do you use signals/slots (readyRead signal)? I guess you don't...
-
Hello, I am exchanging data with the CPU via serial port. The data coming from the CPU appears missing on my console screen. How can I fix this?
QByteArray dataPacket = serial->readAll();
This is how I read the incoming data packet.The value I want to display on the console screen: Main data coming via Serial Port "\x02\x00\xB0\x13\x0F\xFA\x02\xCE\x03"
but The value I see: "\x02\x00\xB0\x13\x0F"This post is deleted! -
@Rumeysa_135 said in Serial Port Data Loss:
exchanging data with the CPU via serial port
CPU?!
"This is how I read the incoming data packet" - where and when do you do this? Do you use signals/slots (readyRead signal)? I guess you don't...
@jsulm
I am using ReadWrite signal.
serial->open(QIODevice::ReadWrite) -
@jsulm
I am using ReadWrite signal.
serial->open(QIODevice::ReadWrite)@Rumeysa_135 said in Serial Port Data Loss:
ReadWrite signal.
What is ReadWrite signal?!
What you need to do is to connect a slot to readyRead signal and in this slot call serial->readAll() and accumulate the data until you got everything (you will not always get all data at once when calling readAll). -
@Rumeysa_135 said in Serial Port Data Loss:
ReadWrite signal.
What is ReadWrite signal?!
What you need to do is to connect a slot to readyRead signal and in this slot call serial->readAll() and accumulate the data until you got everything (you will not always get all data at once when calling readAll).@jsulm How do I handle accumulating data until I have everything?
-
@jsulm How do I handle accumulating data until I have everything?
@Rumeysa_135 Hi,
You keep a buffer that you append to each time
readyReadis fired and check for when you have a full frame of your data in there. Then take the data out of the buffer and process it.