public object ParseResponse(byte[] response, int offset) { Assert.Equal(ModbusHelper.GetUShort(response, offset + 0), transactionId, "TransactionId mismatch {0} {1}"); Assert.Equal(ModbusHelper.GetUShort(response, offset + 2), 0, "Zero mismatch {0} {1}"); Assert.Equal(ModbusHelper.GetUShort(response, offset + 4), wrapped.ResponseLength, "Length mismatch {0} {1}"); return(wrapped.ParseResponse(response, offset + 6)); }
public object ParseResponse(byte[] response, int offset) { var crc1 = ModbusHelper.CRC16(response, offset, wrapped.ResponseLength); //crc is little endian page 13 http://modbus.org/docs/Modbus_over_serial_line_V1_02.pdf var crc2 = ModbusHelper.GetUShortLittleEndian(response, offset + wrapped.ResponseLength); Tools.AssertEqual(crc2, crc1, "CRC mismatch got {0:X4} expected {1:X4}"); return(wrapped.ParseResponse(response, offset)); }