i need buffer for serial communication
Unsolved
General and Desktop
-
I get a total of 10 bytes of data starting with 0xAA.
data sometimes comes in 2 parts.
for instance;
xAA,x00,x10,x00 -> 4byte
x40,x00,x10,x00,x10,x00 -> 6byteWhen the data comes in 2 parts like this, I could not find a solution with buffer how to combine it.
I don't know how to think as I've never used a buffer before -
@KARMA said in i need buffer for serial communication:
I could not find a solution with buffer how to combine it
Simply use a QByteArray member variable in your class and append incoming data to it until you got everything.
-
Hi
- I don't know how to think as I've never used a buffer before
In your Mainwindow / where serialport lives, add in the .h / class
QByteArray data; // the buffer
then in the read slot
void MainWindow::readData() { data.append(m_serial->readAll( ) ); if (data.size() == 10 ) { // do processing data.clear(); } }