Exemplo n.º 1
0
        public void FillRequest(byte[] request, int offset)
        {
            wrapped.FillRequest(request, offset);
            var crc = ModbusHelper.CRC16(request, offset, wrapped.RequestLength);

            request[offset + wrapped.RequestLength + 0] = ModbusHelper.Low(crc);
            request[offset + wrapped.RequestLength + 1] = ModbusHelper.High(crc);
        }
Exemplo n.º 2
0
        public void FillResponse(byte[] response, int offset, object value)
        {
            wrapped.FillResponse(response, offset, value);
            var crc = ModbusHelper.CRC16(response, offset, wrapped.ResponseLength);

            response[offset + wrapped.ResponseLength + 0] = ModbusHelper.Low(crc);
            response[offset + wrapped.ResponseLength + 1] = ModbusHelper.High(crc);
        }
Exemplo n.º 3
0
 public void FillRequest(byte[] request, int offset)
 {
     request[offset + 0] = slave;
     request[offset + 1] = 1;
     request[offset + 2] = ModbusHelper.High(address);
     request[offset + 3] = ModbusHelper.Low(address);
     request[offset + 4] = ModbusHelper.High(count);
     request[offset + 5] = ModbusHelper.Low(count);
 }
Exemplo n.º 4
0
 public void FillRequest(byte[] request, int offset)
 {
     request[offset + 0] = slave;
     request[offset + 1] = 5;
     request[offset + 2] = ModbusHelper.High(address);
     request[offset + 3] = ModbusHelper.Low(address);
     request[offset + 4] = ModbusHelper.EncodeBool(value);
     request[offset + 5] = 0;
 }
 public void FillResponse(byte[] response, int offset, object value)
 {
     response[offset + 0] = slave;
     response[offset + 1] = 16;
     response[offset + 2] = ModbusHelper.High(address);
     response[offset + 3] = ModbusHelper.Low(address);
     response[offset + 4] = ModbusHelper.High(values.Length);
     response[offset + 5] = ModbusHelper.Low(values.Length);
 }
Exemplo n.º 6
0
 public void FillResponse(byte[] response, int offset, object value)
 {
     response[offset + 0] = ModbusHelper.High(transactionId);
     response[offset + 1] = ModbusHelper.Low(transactionId);
     response[offset + 2] = 0;
     response[offset + 3] = 0;
     response[offset + 4] = ModbusHelper.High(wrapped.ResponseLength);
     response[offset + 5] = ModbusHelper.Low(wrapped.ResponseLength);
     wrapped.FillResponse(response, offset + 6, value);
 }
Exemplo n.º 7
0
 public void FillRequest(byte[] request, int offset)
 {
     request[offset + 0] = ModbusHelper.High(transactionId);
     request[offset + 1] = ModbusHelper.Low(transactionId);
     request[offset + 2] = 0;
     request[offset + 3] = 0;
     request[offset + 4] = ModbusHelper.High(wrapped.RequestLength);
     request[offset + 5] = ModbusHelper.Low(wrapped.RequestLength);
     wrapped.FillRequest(request, offset + 6);
 }
Exemplo n.º 8
0
        public byte[] GetException(byte code)
        {
            var exception = new byte[5];

            exception[0] = wrapped.Slave;
            exception[1] = (byte)(wrapped.Code | 0x80);
            exception[2] = code;
            var crc = ModbusHelper.CRC16(exception, 0, 3);

            exception[3] = ModbusHelper.Low(crc);
            exception[4] = ModbusHelper.High(crc);
            return(exception);
        }
Exemplo n.º 9
0
        public byte[] GetException(byte code)
        {
            var exception = new byte[9];

            exception[0]     = ModbusHelper.High(transactionId);
            exception[1]     = ModbusHelper.Low(transactionId);
            exception[2]     = 0;
            exception[3]     = 0;
            exception[4]     = ModbusHelper.High(3);
            exception[5]     = ModbusHelper.Low(3);
            exception[6 + 0] = wrapped.Slave;
            exception[6 + 1] = (byte)(wrapped.Code | 0x80);
            exception[6 + 2] = code;
            return(exception);
        }