Message
The Message base class is intended to provide a wrapper around message class implementations independent of transport layer (like TCP/IP or CAN).
- class pyolcb.Message(message_type: MessageTypeIndicator, data: bytes | bytearray = None, source: Address = None, destination: Address = None, frame_id: int = None)
- classmethod from_can_message(message)
Convert a received frame into a
Message.Accepts a
can.Messageor apyolcb.frame.Frame(anything witharbitration_id,dataandis_extended_id). ReturnsNonefor CAN control frames and unknown MTIs. The destination of an addressed message or datagram is filled in as an alias-onlyAddress.
Event
- class pyolcb.Event(event_id: str | list[int] | int | bytes | bytearray, source: Address = None)
Datagram
- class pyolcb.Datagram(data: bytes | bytearray, source: Address, destination: Address)
A datagram: up to 72 bytes sent reliably to one node, split across as many as nine CAN frames.
- Parameters:
data (bytes | bytearray) – The datagram content. The first byte identifies the protocol (0x20 is Memory Configuration).
source (Address) – The sending node.
destination (Address) – The receiving node (its alias is required to build frames).
Message Types
The message_types module contains all currently defined message types, packaged into a MessageTypeIndicator class to properly handle different Interface types.
- pyolcb.message_types.is_known_mti(mti: MessageTypeIndicator | int) bool
True if
mti(an MTI object or its 16-bit value) is in the table above.
- pyolcb.message_types.name_of(mti: MessageTypeIndicator | int) str
A readable name for an MTI, given as an object, its 16-bit value, or the 12-bit value from a CAN header. Unknown values come back as hex.