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¶
-
can.
detect_available_configs
(interfaces=None)[source]¶ Detect all configurations/channels that the interfaces could currently connect with.
This might be quite time consuming.
Automated configuration detection may not be implemented by every interface on every platform. This method will not raise an error in that case, but with rather return an empty list for that interface.
Parameters: interfaces – either - the name of an interface to be searched in as a string, - an iterable of interface names to search in, or - None to search in all known interfaces. Return type: list[dict] Returns: an iterable of dicts, each suitable for usage in the constructor of can.BusABC
.
Notifier¶
The Notifier object is used as a message distributor for a bus.
-
class
can.
Notifier
(bus, listeners, timeout=1.0, loop=None)[source]¶ Bases:
object
Manages the distribution of
can.Message
instances to listeners.Supports multiple buses and listeners.
Note
Remember to call stop() after all messages are received as many listeners carry out flush operations to persist data.
Parameters: -
add_listener
(listener)[source]¶ Add new Listener to the notification list. If it is already present, it will be called two times each time a message arrives.
Parameters: listener ( Listener
) – Listener to be added to the list to be notified
-
exception
= None¶ Exception raised in thread
-
remove_listener
(listener)[source]¶ Remove a listener from the notification list. This method trows an exception if the given listener is not part of the stored listeners.
Parameters: listener ( Listener
) – Listener to be removed from the list to be notifiedRaises: ValueError – if listener was never added to this notifier
-