Beispiel #1
0
        public Status CheckResponse(byte[] Response)
        {
            if (Response.Length < 9)
            {
                return(Status.Error);
            }

            if (
                (Header.TransactionID != (Response[0] << 8) + Response[1]) ||
                (Header.ProtocolID != (Response[2] << 8) + Response[3]) ||
                (Header.Lenght != (Response[4] << 8) + Response[5]) ||
                (Header.UnitID != Response[6]))
            {
                return(Status.Error);
            }


            if ((Response.Length == RespSize) || (Response.Length == 5))
            {
                var PDUResponse = new byte[Response.Length - 3];
                Array.Copy(Response, 1, PDUResponse, 0, PDUResponse.Length);
                return(PDU.CheckResponse(PDUResponse));
            }
            else
            {
                return(Status.Error);
            }
        }
Beispiel #2
0
        public Status CheckResponse(byte[] Response)
        {
            if (Response.Length < 5)
            {
                return(Status.Error);
            }

            if ((CRC.Get(Response) != 0) && (Response[0] == Device.Address))
            {
                return(Status.Error);
            }

            if ((Response.Length == RespSize) || (Response.Length == 5))
            {
                var PDUResponse = new byte[Response.Length - 3];
                Array.Copy(Response, 1, PDUResponse, 0, PDUResponse.Length);
                return(PDU.CheckResponse(PDUResponse));
            }
            else
            {
                return(Status.Error);
            }
        }