当前位置: 技术问答>linux和unix
谁能根据下面的英文说明帮忙写一个算法?
来源: 互联网 发布时间:2015-12-02
本文导语: 英文说明如下: The Checksum is initially set to zero and is the 16-bit binary addition (excluding parity if applicable) of all characters after, but not including, the SOH character and through (and including) the ETX character. 我的理解是这...
英文说明如下:
The Checksum is initially set to zero and is the 16-bit binary
addition (excluding parity if applicable) of all characters after,
but not including, the SOH character and through (and
including) the ETX character.
我的理解是这样的:
输入为unsigned char类型的数组,数组以SOH开始,以ETX结束。要用除SOH之外的其他部分来计算Checksum。
不明白的地方是"16-bit binary addition",有两点疑惑:
1. 16-bit要怎么处理?数据类型怎么定义?
2. binary addition是不是异或运算?
谁能帮忙写个算法或者指点一下,非常感谢!!!
The Checksum is initially set to zero and is the 16-bit binary
addition (excluding parity if applicable) of all characters after,
but not including, the SOH character and through (and
including) the ETX character.
我的理解是这样的:
输入为unsigned char类型的数组,数组以SOH开始,以ETX结束。要用除SOH之外的其他部分来计算Checksum。
不明白的地方是"16-bit binary addition",有两点疑惑:
1. 16-bit要怎么处理?数据类型怎么定义?
2. binary addition是不是异或运算?
谁能帮忙写个算法或者指点一下,非常感谢!!!
|
1,校验和结果放入16bit数。
2,不是,异或应该是xor吧
2,不是,异或应该是xor吧
|
我们的串口接收数据,就是用的这个算法.