public void DecodeBoolsTest() { Assert.AreEqual(bo(), ModbusHelper.DecodeBools(by(0x00), 1, 0)); Assert.AreEqual(bo(true, false, true), ModbusHelper.DecodeBools(by(0x00, 0x05), 1, 3)); Assert.AreEqual(bo(true, false, true, false, false, false, false, false, false, true), ModbusHelper.DecodeBools(by(0x00, 0x05, 0x02), 1, 10)); }
public object ParseResponse(byte[] response, int offset) { var bytes = ModbusHelper.BytesForBools(Count); Assert.Equal(response[offset + 0], Slave, "Slave mismatch got {0} expected {1}"); Assert.Equal(response[offset + 1], 2, "Function mismatch got {0} expected {1}"); Assert.Equal(response[offset + 2], bytes, "Bytes mismatch got {0} expected {1}"); return(ModbusHelper.DecodeBools(response, offset + 3, Count)); }
private static IModbusCommand Parse15(byte slave, byte code, ushort address, byte[] request, int offset) { var count = ModbusHelper.GetUShort(request, offset + 4); var values = ModbusHelper.DecodeBools(request, offset + 7, count); var bytes = request[offset + 6]; Assert.Equal(ModbusHelper.BytesForBools(count), bytes, "Byte count mismatch got {0} expected {1}"); return(new ModbusF15WriteCoils(slave, address, values)); }