inspect() Function

metlinkpid.inspect(bytes_in: bytes) → metlinkpid.Message

The inspect() function is used to determine how the display would interpret an arbitrary sequence of bytes.

It de-frames & CRC-checks the data (if a DLE/STX/ETX packet is provided), then compares the header against the headers of all known Message types, then constructs an object of the matching type.

The inspect() function is used internally by PID.send() to ensure that a valid ResponseMessage is received after each transmission.

Returns

a DisplayMessage object, a PingMessage object, or a ResponseMessage object.

Raises

ValueError – if a DLE/STX/ETX packet is provided with a bad CRC checksum, or if the bytes can’t be understood.