CANgaroo Python API Reference
May 28, 2026 ยท View on GitHub
The embedded cangaroo module allows you to interact with the CANgaroo measurement backend directly from your scripts.
cangaroo.Message Class
The primary class for constructing and interpreting CAN messages.
Properties
id(int): The CAN message ID.dlc(int): The length of the payload in bytes (Data Length Code).extended(bool):Trueif it is an extended (29-bit) ID,Falsefor standard (11-bit).fd(bool):Trueif the frame is a CAN FD frame.rtr(bool):Trueif the frame is a Remote Transmission Request.brs(bool):Trueif the CAN FD frame has Bit Rate Switching enabled.interface_id(int, read-only): The ID of the interface that received this message.timestamp(float, read-only): The reception timestamp in seconds.is_rx(bool, read-only):Trueif the message was received from the bus (RX),Falseif it was transmitted locally (TX).bustype(str, read-only): The bus type (returns"CAN").
Methods
get_byte(index: int) -> int: Get the value of a specific data byte (0-63).set_byte(index: int, value: int): Set the value of a specific data byte.get_data() -> bytes: Returns the entire payload as a Pythonbytesobject.set_data(data: bytes): Sets the payload to the provided bytes and automatically updates thedlcproperty based on the length of the bytes provided (capped at 64).
CAN Interfaces
To send a message to a specific hardware interface, you must provide the interface_id. By default, functions use interface 0 (the first available interface).
-
cangaroo.interfaces() -> list[dict]Returns a list of dictionaries representing the active interfaces. Example Output:[{'id': 0, 'name': 'can0'}, {'id': 1, 'name': 'vcan0'}] -
cangaroo.interface_name(id: int) -> strReturns the human-readable string name of the given interface ID.
Transmission (TX)
-
cangaroo.send(msg: cangaroo.Message, interface_id: int = 0)Sends a single CAN message over the specified interface. -
cangaroo.send_periodic(msg: cangaroo.Message, interval_ms: int, interface_id: int = 0) -> intStarts a background periodic transmission of the message at the requested interval. Returns a unique integerhandlefor the periodic task. -
cangaroo.stop_periodic(handle: int)Stops a running periodic background task using thehandlereturned bysend_periodic().
Reception (RX)
-
cangaroo.receive(timeout_sec: float = 1.0) -> list[cangaroo.Message]Blocks execution until messages are received or the timeout is reached. Returns a list ofcangaroo.Messageobjects. -
cangaroo.set_filter(id: int, mask: int = 0xFFFFFFFF, extended: bool = None)Applies a filter to thereceive()queue. Only messages matching(received_id & mask) == (id & mask)will be enqueued. -
cangaroo.clear_filter()Removes the active receive filter, allowing all messages to be caught byreceive(). -
cangaroo.enable_tx_echo(enabled: bool = True)By default,receive()only returns actual incoming (RX) messages. Calling this withTruecauses locally sent messages (TX echo) to also appear inreceive().
Trace Window Access
-
cangaroo.get_trace(count: int = 0) -> list[cangaroo.Message]Retrieves the lastcountmessages directly from the global CANgaroo Trace View. Ifcountis 0 or omitted, it retrieves the entire trace buffer. -
cangaroo.trace_size() -> intReturns the total number of messages currently stored in the Trace View. -
cangaroo.clear_trace()Wipes the Trace View history clean.
Measurement Control & Logging
-
cangaroo.start_measurement() -> boolStarts the CANgaroo measurement (equivalent to clicking the Play button). ReturnsTrueon success. -
cangaroo.stop_measurement() -> boolStops the active CANgaroo measurement. -
cangaroo.measurement_running() -> boolReturnsTrueif measurement is currently active. -
cangaroo.log_info(text: str)Logs an informational message to the CANgaroo Log view. -
cangaroo.log_warning(text: str)Logs a warning message (yellow) to the CANgaroo Log view. -
cangaroo.log_error(text: str)Logs an error message (red) to the CANgaroo Log view.