示例#1
0
 protected byte[] PackExceptionResponse(EModbusExceptionCode exceptionCode)
 {
     byte[] data = new byte[9];
     PackHeader(3, data);
     data[7] = (byte)((byte)FunctionCode + 0x80);
     data[8] = (byte)exceptionCode;
     return(data);
 }
        public override Dictionary <Tuple <EPointType, ushort>, ushort> ParseResponse(byte[] response, out EModbusExceptionCode exceptionCode)
        {
            exceptionCode = EModbusExceptionCode.NO_EXCEPTION;
            Dictionary <Tuple <EPointType, ushort>, ushort> parsed = new Dictionary <Tuple <EPointType, ushort>, ushort>();

            if (response[7] != param.FunctionCode)
            {
                exceptionCode = GetExceptionCode(response[8]);
                return(parsed);
            }

            ushort address = param.StartAddress;

            for (int i = 0; i < response[8]; i += 2)
            {
                ushort value = UnpackUInt16(response, i + 9);
                parsed.Add(new Tuple <EPointType, ushort>(EPointType.ANALOG_INPUT, address), value);
                address++;
            }

            return(parsed);
        }
示例#3
0
 public abstract Dictionary <Tuple <EPointType, ushort>, ushort> ParseResponse(byte[] response, out EModbusExceptionCode exceptionCode);