this is my code : (I used qextserialport)
SerialPort::SerialPort(QString port)
{
sp=new QextSerialPort;
sp->setPortName(port);
/*port->setBaudRate(BAUD9600);
port->setFlowControl(FLOW_OFF);
port->setParity(PAR_NONE);
port->setDataBits(DATA_8);
port->setStopBits(STOP_2);*/
sp->setBaudRate(BAUD115200);
sp->setDataBits(DATA_8);
sp->setFlowControl(FLOW_OFF);
sp->setParity(PAR_NONE);
sp->setStopBits(STOP_1);
sp->open(QIODevice::ReadWrite);
connect(sp,SIGNAL(readyRead()),this,SLOT(ReadData()));
}
void SerialPort::ReadData()
{
QByteArray ba;
ba.resize(512);
ba=sp->readAll();
emit DataRecieve(ba);
}
this code run on Ubuntu at first and show all the bytes which receive from device, but when I tested it in linux embedded device this code read data from serial device in 2 part. () there is no \n in my bytes. I change the code to this code :
void SerialPort::ReadData()
{
QByteArray ba;
ba.resize(512);
if(sp->bytesAvailable()>0 || sp->waitForReadyRead(20000))
{
qDebug()<<sp->bytesAvailable();
ba=sp->readAll();
qDebug()<<ba.toHex();
emit DataRecieve(ba);
}
}
but again my output is :
4 "aa5524010400000000000000"
12 "000000000000000000002801"
but it should be :
"aa5524010400000000000000000000000000000000002801"
My output size is maybe 48 bytes or 512 bytes