Library API¶
The main objects are the BusABC and the Message.
A form of CAN interface is also required.
Hint
Check the backend specific documentation for any implementation specific details.
Utilities¶
Configuration file parsing.
-
can.util.choose_socketcan_implementation()[source]¶ Set the best version of SocketCAN for this system.
Parameters: config – The can.rc configuration dictionary Raises: Exception – If the system doesn’t support SocketCAN
-
can.util.load_config(path=None)[source]¶ Returns a dict with configuration details which is loaded from (in this order):
- Environment variables CAN_INTERFACE, CAN_CHANNEL
- Config files
/etc/can.confor~/.canor~/.canrcwhere the latter may add or replace values of the former.
Interface can be kvaser, socketcan, socketcan_ctypes, socketcan_native, serial
The returned dictionary may look like this:
{ 'interface': 'python-can backend interface to use', 'channel': 'default channel to use', }
Parameters: path – Optional path to config file.
Notifier¶
The Notifier object is used as a message distributor for a bus.
-
class
can.Notifier(bus, listeners, timeout=None)[source]¶ Bases:
objectManages the distribution of Messages from a given bus to a list of listeners.
Parameters: - bus – The Bus to listen too.
- listeners – An iterable of
Listeners - timeout – An optional maximum number of seconds to wait for any message.