下载此文档

PM2.5传感器Modbusrtu通讯协议.doc


文档分类:通信/电子 | 页数:约4页 举报非法文档有奖
1/4
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/4 下载此文档
文档列表 文档介绍
PM2.5传感器Modbusrtu通讯协议.doc:..-、标准modbus协议说明1、串口设置波特率9600,无校验,数据位8,停止位1。力能通讯命令16进制:00030000000185DB(不清楚设备地址可用此找冋)2、接口说明请接入GND(地\电源负极),TX(模组串口发对应串口线收),RX(模组串口收对应串口线发)对应接口。调试不通请交换串口线再试。4、CRC16校验计算函数(请确认单片机人端编程还是小端)返回shortint参数data【】数组、Ion数组长度例子:datax[8]={01,03,00,00,00,01,00,00}16进制unsignedshortintx=CRC_16(datax,6);得到x=0x840a;sixxlx /吓、XT%ZJX IunsignedshortintCRC_16(unsignedchar*data,intlen)unsignedchar*buf;unsignedshortint*CRC;unsignedshortintcrch,crcl;shortinti;shortintj;charerr;buf=&data[len];CRC=(unsignedshortint*)buf;buf[0]=0xff;buf[l]=0xff;for(i=0;i<len;i++){buf[0]=buf[0]"data[i];for(j=0;j<8;j++)!err=buf[0]&l;*CRC=*CRC/2;if(err)*CRO*CRCfOxaOO1;}}crch=*CRC>>8;crcl=*CRC«8;*CRC=crch+crcl;return(*CRC);/******************函数CRC_16()*********小端返回shortint参数data【】数组、len数组长度例子:datax[8]={01,03,00,00,00,01,00,00}16进制unsignedshortintx=CRC_16(datax,

PM2.5传感器Modbusrtu通讯协议 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数4
  • 收藏数0 收藏
  • 顶次数0
  • 上传人ttteee8
  • 文件大小70 KB
  • 时间2019-09-17