I would like to extract each time the data bytes of my IMU data which are in the following form:
"5555 41321e7fea02a2efb400010005fffe00d6fff90cbb261926192619006692340000bf5f"
I would like to make sure that the data received header 0x5555 , because The packet header is always the bit pattern 0x5555.
I tried with this code but it doesn't give anything, I don't really know how to read the bytes of a packet ( sorry I am a beginner ) .
void Imu::pollSerialPort()
{
static const unsigned char START_BYTES[2] = {0x55};
static const QByteArray START_WORD((char*)START_BYTES,2);
int numToPop=0;
static QTime startTime = QTime::currentTime();
QByteArray data= serialPort->readAll().toHex();
qDebug() << "Serial received " << data;
// find header
for(numToPop=0; numToPop+1<data.size() ;numToPop+=1)
{
if(0x55==data.indexOf(START_WORD))
break;
else
log_warning("imu","dropping %d bytes before header recovery");
/* header was not found */
}