Dears,
I am writing a server application for some GPS devices and I am having trouble with the receiving data.
The server is working fine, it receives the header as expected and writes to the device, but the data expected to be received is as shown:
080400000113fc208dff000f14f650209cca80006f00d6040004000403010115031603000
1460000015d0000000113fc17610b000f14ffe0209cc580006e00c0050001000403010115
0316010001460000015e0000000113fc284945000f150f00209cd20000950108040000000
4030101150016030001460000015d0000000113fc267c5b000f150a50209cccc000930068
0400000004030101150016030001460000015b0004
080400000113fc208dff000f14f650209cca80006f00d6040004000403010115031603000
1460000015d0000000113fc17610b000f14ffe0209cc580006e00c0050001000403010115
0316010001460000015e0000000113fc284945000f150f00209cd20000950108040000000
4030101150016030001460000015d0000000113fc267c5b000f150a50209cccc000930068
0400000004030101150016030001460000015b0004
To copy to clipboard, switch view to plain text mode
but the data received is:
7811a7b728990508100000001100000098020508000000000000000069000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000058060508000000000000000011000000000000000000000000000000110000006877e3b7000000000000000011000000e874e3b7000000000000000011000000a873e3b7000000000000000011000000a873e3b7010000000000000021000000c80905080040a7b780a2f8b700000000c80905080040a7b780a2f8b71100000002000000010000000000000011000000a873e3b7020000000000000011000000a873e3b7030000000000000039000000c803050802000000c8090508801c5eebe01e5eebd01e5eeb2f7573722f6c69622f67636f6e762f5554462d31362e736f0000000011000000a873e3b7040000000000000011000000a873e3b70500000000000000190000001404050808000000a80c05080900000001000000290000000100000003000000020000000300000001000000e80005083330322f80d4c0b7b4b0e3b711000000a873e3b7060000000000000011000000a873e3b707000000000000003900000001000000040000000300000001000000
7811a7b728990508100000001100000098020508000000000000000069000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000058060508000000000000000011000000000000000000000000000000110000006877e3b7000000000000000011000000e874e3b7000000000000000011000000a873e3b7000000000000000011000000a873e3b7010000000000000021000000c80905080040a7b780a2f8b700000000c80905080040a7b780a2f8b71100000002000000010000000000000011000000a873e3b7020000000000000011000000a873e3b7030000000000000039000000c803050802000000c8090508801c5eebe01e5eebd01e5eeb2f7573722f6c69622f67636f6e762f5554462d31362e736f0000000011000000a873e3b7040000000000000011000000a873e3b70500000000000000190000001404050808000000a80c05080900000001000000290000000100000003000000020000000300000001000000e80005083330322f80d4c0b7b4b0e3b711000000a873e3b7060000000000000011000000a873e3b707000000000000003900000001000000040000000300000001000000
To copy to clipboard, switch view to plain text mode
and the slot (connected to readyRead() signal) that I am handling the received data is as shown:
// Just for verification
qDebug() << "Bytes Available: " << tcpClient->bytesAvailable();
quint16 header;
in >> header; // reading header
char *data = new char[header];
// reading raw data on the char pointer above
in.readRawData(data, header);
// displaying "crazy" data as shown above
printf(b.toHex());
// sending accepted message to the device
// otherwise the device won't send you the data back
out << true;
tcpClient->write(ba);
// Just for verification
qDebug() << "Bytes Available: " << tcpClient->bytesAvailable();
QDataStream in(tcpClient);
quint16 header;
in >> header; // reading header
char *data = new char[header];
// reading raw data on the char pointer above
in.readRawData(data, header);
QByteArray b(data, tcpClient->bytesAvailable());
// displaying "crazy" data as shown above
printf(b.toHex());
// sending accepted message to the device
// otherwise the device won't send you the data back
QByteArray ba;
QDataStream out(&ba, QIODevice::WriteOnly);
out << true;
tcpClient->write(ba);
To copy to clipboard, switch view to plain text mode
Any suggestions what I am doing wrong?
Sincerely,
Milot.
Bookmarks