옵션 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | //#1 typedef struct { unsigned char SlaveAddr; enum enum_ModbusFunc { ReadHolding = 0x03, PresetSingle = 0x06 } Func; unsigned int RegAddr; signed int Data; unsigned char *Buf; }tag_ModbusRequest; void ModbusRequest(tag_ModbusRequest *Req); /**********************************************/ Poll.SlaveAddr = 1; Poll.Func = ReadHolding; Poll.RegAddr = 239; Poll.Data = 9; Poll.Buf = Com2TxQue; ModbusRequest(&Poll); //#2 enum enum_ModbusFunc { ReadHolding = 0x03, PresetSingle = 0x06 }; void ModbusRequest(unsigned char SlaveAddr, enum_ModbusFunc Func, unsigned int RegAddr, signed int Data, unsigned char *Buf); /**********************************************/ ModbusRequest(1, ReadHolding, 239, 9, Com2TxQue); | cs |