public ModBus(ModBusMode mode, int port, int baudrate, SerialPortMode serialPortMode) { Mode = mode; Port = port; Baudrate = baudrate; SerialPortMode = serialPortMode; HardwareInterface = new HardwareInterface(port, baudrate, new Commands[] { Commands.SendOverSerialPort, Commands.InitSerialPort }); PendingReadRequestList = new SyncList <ModBusReadRequest>(); _maxSendCapacity = SettingManager.Instance.Settings.MaxSendListCapacity; HardwareInterface.OnReceiceNewPacket += HardwareInterface_OnReceiceNewPacket; }
public Result InitSerialPort(int port, int baudrate, SerialPortMode mode) { return(_cm.SendPacket(new Packet() { Command = Commands.InitSerialPort, CommandParam = (byte)port, IsWaitForResponse = true, Data = new byte[] { (byte)(baudrate >> 24), (byte)(baudrate >> 16), (byte)(baudrate >> 8), (byte)(baudrate), (byte)mode, } })); }