milot
7th April 2010, 16:11
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:
080400000113fc208dff000f14f650209cca80006f00d60400 04000403010115031603000
1460000015d0000000113fc17610b000f14ffe0209cc580006 e00c0050001000403010115
0316010001460000015e0000000113fc284945000f150f0020 9cd20000950108040000000
4030101150016030001460000015d0000000113fc267c5b000 f150a50209cccc000930068
0400000004030101150016030001460000015b0004
but the data received is:
7811a7b7289905081000000011000000980205080000000000 00000069000000010000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000110000005806050800000000000000001100 0000000000000000000000000000110000006877e3b7000000 000000000011000000e874e3b7000000000000000011000000 a873e3b7000000000000000011000000a873e3b70100000000 00000021000000c80905080040a7b780a2f8b700000000c809 05080040a7b780a2f8b7110000000200000001000000000000 0011000000a873e3b7020000000000000011000000a873e3b7 030000000000000039000000c803050802000000c809050880 1c5eebe01e5eebd01e5eeb2f7573722f6c69622f67636f6e76 2f5554462d31362e736f0000000011000000a873e3b7040000 000000000011000000a873e3b7050000000000000019000000 1404050808000000a80c050809000000010000002900000001 00000003000000020000000300000001000000e80005083330 322f80d4c0b7b4b0e3b711000000a873e3b706000000000000 0011000000a873e3b707000000000000003900000001000000 040000000300000001000000
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();
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);
Any suggestions what I am doing wrong?
Sincerely,
Milot.
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:
080400000113fc208dff000f14f650209cca80006f00d60400 04000403010115031603000
1460000015d0000000113fc17610b000f14ffe0209cc580006 e00c0050001000403010115
0316010001460000015e0000000113fc284945000f150f0020 9cd20000950108040000000
4030101150016030001460000015d0000000113fc267c5b000 f150a50209cccc000930068
0400000004030101150016030001460000015b0004
but the data received is:
7811a7b7289905081000000011000000980205080000000000 00000069000000010000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000110000005806050800000000000000001100 0000000000000000000000000000110000006877e3b7000000 000000000011000000e874e3b7000000000000000011000000 a873e3b7000000000000000011000000a873e3b70100000000 00000021000000c80905080040a7b780a2f8b700000000c809 05080040a7b780a2f8b7110000000200000001000000000000 0011000000a873e3b7020000000000000011000000a873e3b7 030000000000000039000000c803050802000000c809050880 1c5eebe01e5eebd01e5eeb2f7573722f6c69622f67636f6e76 2f5554462d31362e736f0000000011000000a873e3b7040000 000000000011000000a873e3b7050000000000000019000000 1404050808000000a80c050809000000010000002900000001 00000003000000020000000300000001000000e80005083330 322f80d4c0b7b4b0e3b711000000a873e3b706000000000000 0011000000a873e3b707000000000000003900000001000000 040000000300000001000000
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();
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);
Any suggestions what I am doing wrong?
Sincerely,
Milot.