[Solved] Need help in QSerial Port in Qt5.1
Hello I am Beginner in QT,
Now I am using QSerial port for uart communication, to read the data which send from Hardware. I used below code for reading data.
@rs232_ = new QSerialPort(this);
qDebug()<<"...Port ttyS0 Cannot Open..."<<endl;
connect(rs232_, SIGNAL(readyRead()), this, SLOT(process()));@
QByteArray lineLength = rs232_->readAll();
QString temp = lineLength.toHex();
condata(temp); //binary conversion
Problem is while reading it misses some data, and add ZERO 's in output
fe 85 a 0 0 0 2b 96 0 5 2 0 0 0
And the recived packages are in wrong order.
order shoud be , first byte : 7 bit Must be 1 (10000000), then following bytes 2,3,4,5 will be read and displayed.
what happens is,
7 bit is readed as 1 and following bytes order are changed randomly.
the size of data recives are not constant
For resolving this problem i used read(); readline(); readlinedata();but result was same.
Also Tried in
QExt serial port,
And C Program for serail port.
1StartBit+8Data Bit+1StopBit / 4800BAUD RATE/ ODD Parity
5bytes in single package, 60 packages for 1 sec.
Ubuntu 12.04, 32-bit,
is there any solution for this?__
Did you also set the start bit ?
You should store everything you received and once you have enough data parse it. readyRead will be emitted frequently but not at the same pace as the protocol. Don't forget to discard the first byte you received until you have a package start byte.
Hope it helps
What are you trying to show me ?
Just a thank for Reply
Ho ok :)
You're welcome !