Interface
The Interface base class is intended to provide a wrapper around transport layer implementations (like TCP/IP or CAN), with the goal of making each Node instance transport method agnostic.
- class pyolcb.Interface(connection=None)
A connection to an OpenLCB/LCC network.
The base class wraps a python-can bus. GridConnect over TCP and over a serial line are provided by
pyolcb.gridconnect.GridConnectTcpInterfaceandpyolcb.gridconnect.GridConnectSerialInterface, which share this API:send()aMessageorFrame, andregister_listener()to be called with every received frame.- Parameters:
connection (can.BusABC) – The python-can bus to use.
- close()
Release the connection.
- property connected: bool
True while frames can be sent. A CAN bus is always connected.
- register_listener(function: callable)
Register a function to be called with every frame received. On a CAN bus the argument is a
can.Message; on GridConnect interfaces it is aFrame. Both havearbitration_idanddata.
- register_state_listener(function: callable)
Register a function to be called with
Truewhen the interface (re)connects andFalsewhen it loses its connection. A node uses this to claim a fresh alias after every reconnect.