voidpresetSingleRegister(void) //设置单个寄存器{ U8addr; U8tempAddr; U8setCount; U16crcData; U16tempData; //addr=(receBuf[2]8; sendBuf[3]=addr&0xff; sendBuf[4]=receBuf[4]; sendBuf[5]=receBuf[5]; setCount=6; //共6个字节 crcData=crc16(sendBuf,6); sendBuf[6]=crcData>>8; sendBuf[7]=crcData&0xff; sendCount=8; beginSend();}//设置多个寄存器voidpresetMultipleRegisters(void){ UINT8addr; UINT8tempAddr; UINT8byteCount; UINT8setCount; UINT16crcData; UINT16tempData; UINT8i; //addr=(receBuf[2]8; sendBuf[3]=addr&0xff; sendBuf[4]=setCount>>8; sendBuf[5]=setCount&0xff; crcData=crc16(sendBuf,6); sendBuf[6]=crcData>>8; sendBuf[7]=crcData&0xff; sendCount=8; beginSend();}码
2024/6/16 13:03:24
8.16MB
modbus
1