Modbus Rtu Crc16 Calculation
I'm coding a MODBUS CRC16 calculator in C. What I have before is a python that do this, I wanted to convert it to C. I found some codes online but it's not giving me the correct an
Solution 1:
WORDshould beunsigned short(2 bytes), notunsigned long(4 or 8 bytes depended on platform)typedefunsignedshort WORD;As @paddy said, loop from 0 to 6 in the for loop:
for (i=0; i<6; i++) { ... }crc_datashould be of typeWORD, notcharWORD crc_data;use
%04xin lastprintf()printf("this is CRC: %04x\n", crc_data);
Post a Comment for "Modbus Rtu Crc16 Calculation"