modbusrtu协议中的crc算法专业文章

modbusrtu协议中的crc算法专业文章

ID:15839143

大小:122.00 KB

页数:4页

时间:2018-08-06

modbusrtu协议中的crc算法专业文章_第1页
modbusrtu协议中的crc算法专业文章_第2页
modbusrtu协议中的crc算法专业文章_第3页
modbusrtu协议中的crc算法专业文章_第4页
资源描述:

《modbusrtu协议中的crc算法专业文章》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、第:4页,共:4页一、本文重点介绍ModBusRTU协议及协议中的CRC16算法。ModBusRTU协议在仪器仪表、数据采集中(如深圳科立恒公司KM数控仪表、KT2隔离数据采集器)广范应用。二、ModBus协议说明1>ModBusRTU发送协议(读取:03功能码):地址03数据地址(H)数据地址(L)数据长度(H)数据长度(L)CRC(H)CRC(L)例:010300000001840A接收数据格式为:地址03字长数据1(H)数据1(L)...CRC(H)CRC(L)例:0103020000B8442>ModBusRTU发送协议

2、(写入:06功能码)地址06数据地址(H)数据地址(L)新数据(H)新数据(L)CRC(H)CRC(L)例:010600000002080B回复数据格式为(也就把收到的数据不变返回):地址06数据地址(H)数据地址(L)新数据(H)新数据(L)CRC(H)CRC(L)例:010600000002080B第:4页,共:4页三、CRC的生成方法://--------------------------------------------------------------//   CRC16计算方法1:使用2个256长度的校验表//

3、--------------------------------------------------------------constBYTEchCRCHTalbe[]=                                //CRC高位字节值表{0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x4

4、0,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,

5、0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x

6、81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40

7、,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40,0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,第:4页,共

8、:4页0x00,0xC1,0x81,0x40,0x01,0xC0,0x80,0x41,0x01,0xC0,0x80,0x41,0x00,0xC1,0x81,0x40};constBYTEchCRCLTalbe[]=                        

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。