phoenix6.canbus#

Module Contents#

class phoenix6.canbus.CANBusStatus#

Contains status information about a CAN bus.

status: phoenix6.status_code.StatusCode#

Status code response of getting the data

bus_utilization: float = 0#

CAN bus utilization, from 0.0 to 1.0

bus_off_count: int = 0#

Bus off count

tx_full_count: int = 0#

Transmit buffer full count

rec: int = 0#

Receive Error Counter (REC)

tec: int = 0#

Transmit Error Counter (TEC)

class phoenix6.canbus.CANBus(canbus: str = '', hoot_filepath: str | None = None)#

Class for getting information about an available CAN bus.

A CANBus can optionally be constructed with an associated hoot file, which loads it for replay (equivalent to calling HootReplay.load_file).

Only one hoot log may be replayed at a time, so only one CAN bus should be constructed with a hoot file.

When using relative paths, the file path is typically relative to the top-level folder of the robot project.

Parameters:
  • canbus (str, optional) –

    Name of the CAN bus. Possible CAN bus strings are:

    • ”rio” for the native roboRIO CAN bus

    • CANivore name or serial number

    • SocketCAN interface (non-FRC Linux only)

    • ”*” for any CANivore seen by the program

    • empty string (default) to select the default for the system:

      • ”rio” on roboRIO

      • ”can0” on Linux

      • ”*” on Windows

  • hoot_filepath (str | None, optional) – Path and name of the hoot file to load

property name: str#

Get the name used to construct this CAN bus.

Returns:

Name of the CAN bus

Return type:

str

is_network_fd() bool#

Gets whether the CAN bus is a CAN FD network.

Returns:

True if the CAN bus is CAN FD

Return type:

bool

get_status() CANBusStatus#

Gets the status of the CAN bus, including the bus utilization and the error counters.

This can block for up to 0.001 seconds (1 ms).

Returns:

Status of the CAN bus

Return type:

CANBusStatus