Need help in correcting issues in CRC-ITU check method written in Javascript (node.js)

后端 未结 5 1900
甜味超标
甜味超标 2021-01-06 05:15

We are trying to code GPS device listener on Javascript.

While doing this, we are unable to develop the right script for the CRC-ITU error check. The explanation for

5条回答
  •  梦谈多话
    2021-01-06 05:37

    The ~ in the original code only worked because it was a 16-bit type. You should use crcX = crcX ^ 0xffff instead of crcX = ~crcX.

    Also your buf.substring(i,i+4) and i = i + 4 is wrong. You need to process one byte at a time, which is two hexadecimal digits. Those should both be i+2.

提交回复
热议问题