public IModbusWrapper Parse(byte[] request, int offset) { var wrapped = ModbusParser.Parse(request, offset + 6); Assert.Equal(wrapped.RequestLength, ModbusHelper.GetUShort(request, offset + 4), "RequestLength mismatch {0} expected:{1}"); var transaction = ModbusHelper.GetUShort(request, offset); return(new ModbusTCPWrapper(wrapped, transaction)); }
public IModbusWrapper Parse(byte[] request, int offset) { var wrapped = ModbusParser.Parse(request, offset); var crc = ModbusHelper.CRC16(request, offset, wrapped.RequestLength); Assert.Equal(crc, ModbusHelper.GetUShortLittleEndian(request, offset + wrapped.RequestLength), "CRC mismatch {0:X4} expected {1:X4}"); return(new ModbusRTUWrapper(wrapped)); }