数据解析
- int Modbus_Work(void)
- {
- double depth;
- uint16_t depth_high;
- uint16_t depth_low;
- int len = strlen((char*)(sensor485DataBuffer+1));
- if(sensor485DataBuffer[1] == 0x01)//从机地址正确则进行换算
- {
- if((CRC_16((int8_t *)(sensor485DataBuffer+1),len))==0x0000){//CRC校验
- depth_high = sensor485DataBuffer[3];
- depth_low = sensor485DataBuffer[4];
- depth = (double)((depth_high << 8) + depth_low)/1000;
- }
- }memset(sensor485DataBuffer,0,len+1);
- return depth;//这就是水深值了
- }
|