Exemple #1
0
        public object ParseResponse(byte[] response, int offset)
        {
            var bytes = ModbusHelper.BytesForBools(count);

            Assert.Equal(response[offset + 0], slave, "Slave mismatch {0} expected:{1}");
            Assert.Equal(response[offset + 1], 1, "Function mismatch {0} expected:{1}");
            Assert.Equal(response[offset + 2], bytes, "Bytes mismatch {0} expected:{1}");
            return(ModbusHelper.DecodeBools(response, offset + 3, count));
        }
Exemple #2
0
        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];

            Tools.AssertEqual(ModbusHelper.BytesForBools(count), bytes, "Byte count mismatch got {0} expected {1}");
            return(new ModbusF15WriteCoils(slave, address, values));
        }
Exemple #3
0
        public void FillResponse(byte[] response, int offset, object value)
        {
            var bytes = ModbusHelper.BytesForBools(count);

            response[offset + 0] = slave;
            response[offset + 1] = 1;
            response[offset + 2] = bytes;
            var data = ModbusHelper.EncodeBools((bool[])value);

            ModbusHelper.Copy(data, 0, response, offset + 3, bytes);
        }