private MODBUS_TX_MSG ThreadGetMsg(int Offset, int Count) { MODBUS_RX_MSG MBRM = new MODBUS_RX_MSG(); MODBUS_TX_MSG MBTM = new MODBUS_TX_MSG(); MBTM.Buf = new byte[100]; byte[] RxBuffer = new byte[200]; byte[] TxBuffer = new byte[200]; MBRM.Addr = Value.RSValue.RS485Addr; MBRM.FuncCode = 0x03; MBRM.Length = Count; MBRM.Offset = (byte)Offset; int Length = 标准ModBus.CreateMsg_ModBus(MBRM, ref TxBuffer); Length = Usart.SendData(serialPort1, TxBuffer, Length, ref RxBuffer, 200); 标准ModBus.Export_ModBus(ref MBTM, ref RxBuffer); return(MBTM); }
private MODBUS_TX_MSG GetMsg(int Offset, int Count) { MODBUS_RX_MSG MBRM = new MODBUS_RX_MSG(); MODBUS_TX_MSG MBTM = new MODBUS_TX_MSG(); MBTM.Buf = new byte[100]; byte[] RxBuffer = new byte[200]; byte[] TxBuffer = new byte[200]; MBRM.Addr = byte.Parse(comboBox3.Text); MBRM.FuncCode = 0x03; MBRM.Length = Count; MBRM.Offset = (byte)Offset; int Length = 标准ModBus.CreateMsg_ModBus(MBRM, ref TxBuffer); serialPort1.ReadTimeout = 500; Length = Usart.SendData(serialPort1, TxBuffer, Length, ref RxBuffer, 200); 标准ModBus.Export_ModBus(ref MBTM, ref RxBuffer); return(MBTM); }