Listeners¶
Listener¶
The Listener class is an “abstract” base class for any objects which wish to register to receive notifications of new messages on the bus. A Listener can be used in two ways; the default is to call the Listener with a new message, or by calling the method on_message_received.
Listeners are registered with Notifier object(s) which ensure they are notified whenever a new message is received.
Subclasses of Listener that do not override on_message_received will cause NotImplementedError to be thrown when a message is received on the CAN bus.
BufferedReader¶
-
class
can.
BufferedReader
[source]¶ Bases:
can.CAN.Listener
A BufferedReader is a subclass of
Listener
which implements a message buffer: that is, when thecan.BufferedReader
instance is notified of a new message it pushes it into a queue of messages waiting to be serviced.-
get_message
(timeout=0.5)[source]¶ Attempts to retrieve the latest message received by the instance. If no message is available it blocks for given timeout or until a message is received (whichever is shorter),
Parameters: timeout (float) – The number of seconds to wait for a new message. Returns: the Message
if there is one, or None if there is not.
-
Logger¶
-
class
can.
Logger
[source]¶ Bases:
object
Logs CAN messages to a file.
- The format is determined from the file format which can be one of:
- .asc:
can.ASCWriter
- .csv:
can.CSVWriter
- .db:
can.SqliteWriter
- other:
can.Printer
- .asc:
Printer¶
CSVWriter & SqliteWriter¶
These Listeners simply create csv and sql files with the messages received.