public void FillRequest(byte[] request, int offset) { FillResponse(request, offset, null); var bytes = ModbusHelper.EncodeBools(values); request[offset + 6] = (byte)bytes.Length; ModbusHelper.Copy(bytes, 0, request, offset + 7, bytes.Length); }
public void EncodeBoolsTest() { Assert.AreEqual(by(), ModbusHelper.EncodeBools(bo())); Assert.AreEqual(by(0x01), ModbusHelper.EncodeBools(bo(true))); Assert.AreEqual(by(0x03), ModbusHelper.EncodeBools(bo(true, true))); Assert.AreEqual(by(0x13), ModbusHelper.EncodeBools(bo(true, true, false, false, true))); Assert.AreEqual(by(0x13, 0x05), ModbusHelper.EncodeBools(bo(true, true, false, false, true, false, false, false, true, false, true))); }
public void FillResponse(byte[] response, int offset, object value) { var bytes = ModbusHelper.BytesForBools(Count); response[offset + 0] = Slave; response[offset + 1] = 2; response[offset + 2] = bytes; var data = ModbusHelper.EncodeBools(value as bool[]); ModbusHelper.Copy(data, 0, response, offset + 3, bytes); }