Vaisala CRC16
来源:互联网 发布:uptodate数据库 编辑:程序博客网 时间:2024/05/16 09:03
CRC-16 COMPUTATION
Initialize the CRC to zero. For each character beginning with the address, up to but not including the carriage return (<cr>), do as follows:
{
Set the CRC equal to the exclusive OR of the character and itself
for count =1 to 8
{
if the least significant bit of the CRC is one
{
right shift the CRC one bit
set CRC equal to the exclusive OR of 0xA001 and itself
}else{
right shift the CRC one bit
}
}
}
Encoding the CRC as ASCII Characters
The 16 bit CRC is encoded to three ASCII characters by using the following algorithm:
1st character = 0x40 OR (CRC shifted right 12 bits)
2nd character = 0x40 OR ((CRC shifted right 6 bits) AND 0x3F)
3rd character = 0x40 OR (CRC AND 0x3F)
The three ASCII characters are placed between the data and <cr><lf>.
Parity is applied to all three characters, if selected for the character frame.
The CRC computation code is added to the end of the response, if the first letter of the command is sent by using lower case.
void CRC16(BYTE *Array, BYTE *Rcvbuf,unsigned int Len)
{
unsigned int IX,IY,CRC;
CRC=0;
if (Len<=0)
{
CRC = 0;
}else{
Len--;
for (IX=0;IX<=Len;IX++)
{
CRC=CRC^(unsigned int)(Array[IX]);
for(IY=0;IY<=7;IY++)
{
if ((CRC&1)!=0)
{
CRC=(CRC>>1)^0xA001;
}else{
CRC=CRC>>1;
}
}
}
}
Rcvbuf[0] = 0x40 | (CRC >> 12);//高位置
Rcvbuf[1] = 0x40 | ((CRC >> 6) & 0x3F);//中位置
Rcvbuf[2] = 0x40 | (CRC & 0x3F);//低位置
}
- Vaisala CRC16
- CRC16
- crc16
- CRC16
- CRC16
- CRC16计算方法
- CRC16 校验
- CCITT-CRC16
- CRC16校验
- crc16计算
- CRC16校验
- CRC16算法
- CRC16校验
- CRC16校验
- CRC16校验
- crc16校验
- [C#]CRC16
- CRC16 校验
- 换了你,你会杀了谁?
- "处对象了吗?”
- VC2008 开发ICE
- 两道选择题,看完之后我真的只剩下沉默
- 穷人最缺的是野心!
- Vaisala CRC16
- VC++ 操作MySql数据库
- Modbus CRC 算法
- Determining the Size of a Class Object
- WebGIS系统的设计与实现
- ASM + JASMIN combination for java class file editing in bytecode level
- 今天遇到的FPGA奇怪的现象
- XML解析库
- Apache启动问题:overwritten -- Unclean shutdown of previous Apache run