public static ReadHoldingRegisters Create(byte slaveAddress, ushort startingAddress, ushort quantity) { ReadHoldingRegisters request = new ReadHoldingRegisters() { SlaveAddress = slaveAddress, FunctionCode = 3, StartingAddress = (ushort)(startingAddress), QuantityOfRegisters = quantity, Protocol = ProtocolType.RTU }; byte[] rtuEncoded = request.Encode(); return(ReadHoldingRegisters.Decode(rtuEncoded)); }
public static ReadHoldingRegisters Create(byte unitId, ushort transactionId, ushort protocolId, ushort startingAddress, ushort quantity) { ReadHoldingRegisters request = new ReadHoldingRegisters() { Header = new MbapHeader() { ProtocolId = protocolId, TransactionId = transactionId, UnitId = unitId }, SlaveAddress = unitId, FunctionCode = 3, StartingAddress = (ushort)(startingAddress), QuantityOfRegisters = quantity, Protocol = ProtocolType.TCP }; byte[] encoded = request.Encode(); return(ReadHoldingRegisters.Decode(encoded)); }