Tadas
29th May 2011, 17:43
I need to calculate crc-16 for this string:
0A0105000000102347455420444154414F524445520D0A01
Then answer should be: F65B(hex)
I can get this answer using online calculator http://www.zorc.breitbandkatze.de/crc.html
just click button crc-16 and paste line below and click compute
%0A%01%05%00%00%00%10%23%47%45%54%20%44%41%54%41%4 F%52%44%45%52%0D%0A%01
this will give the correct answer F65B, but I want to integrate it in to my qt code.
I was hoping to calculate CRC using qChecksum function.
QByteArray source = QString("0A0105000000102347455420444154414F524445520D0A01").toUtf8();
quint16 crc1 = qChecksum(source.data(), source.length());
qDebug() <<"crc1" <<crc1;
but answer is crc1 18940 (dec), 49FC (hex) , so it is wrong
This page also has a link to C code, but it is hard for me to understand it, i'm new with bytes and bits. http://www.zorc.breitbandkatze.de/crctester.c
Maybe someone could show me, how to do this calculation with qChecksum (if it is possible) or give any other hints.
0A0105000000102347455420444154414F524445520D0A01
Then answer should be: F65B(hex)
I can get this answer using online calculator http://www.zorc.breitbandkatze.de/crc.html
just click button crc-16 and paste line below and click compute
%0A%01%05%00%00%00%10%23%47%45%54%20%44%41%54%41%4 F%52%44%45%52%0D%0A%01
this will give the correct answer F65B, but I want to integrate it in to my qt code.
I was hoping to calculate CRC using qChecksum function.
QByteArray source = QString("0A0105000000102347455420444154414F524445520D0A01").toUtf8();
quint16 crc1 = qChecksum(source.data(), source.length());
qDebug() <<"crc1" <<crc1;
but answer is crc1 18940 (dec), 49FC (hex) , so it is wrong
This page also has a link to C code, but it is hard for me to understand it, i'm new with bytes and bits. http://www.zorc.breitbandkatze.de/crctester.c
Maybe someone could show me, how to do this calculation with qChecksum (if it is possible) or give any other hints.