| | |
| | |
|
| | | int ModBusSlaveCheckPkg(int nChn, void *ptr, uint16_t len1)
|
| | | {
|
| | | if (len1 <=4) return -1; //包长
|
| | | if (len1 <=4) return -1; //����
|
| | | pModBusRTUReqPkg pPkg = (pModBusRTUReqPkg) ptr;
|
| | | if (pPkg->Dst >127) return -2; //地址码
|
| | | if ((pPkg->Cmd&0x7f) > 0x1f) return -3; //功能码
|
| | | uint16_t crc = crc16tablefast(ptr,len1); //CRC 校验
|
| | | if (crc != 0 ) return 4; //CRC 校验错误
|
| | | if (pPkg->Dst >127) return -2; //��ַ��
|
| | | if ((pPkg->Cmd&0x7f) > 0x1f) return -3; //������
|
| | | uint16_t crc = crc16tablefast(ptr,len1); //CRC ��
|
| | | if (crc != 0 ) return 4; //CRC �����
|
| | | return S_OK;
|
| | | }
|
| | |
|