phoenix6.canbus

Module Contents

Attributes

phoenix6.canbus.USE_WPILIB = 'True'
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.

For the native Systemcore CAN buses, use CANBus.systemcore(int, str | None) instead.

For the Motioncore CAN buses, use CANBus.motioncore(int, str | None) instead.

Parameters:
  • canbus (str, optional) –

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

    • ”can_s0” to “can_s24” for the native Systemcore/Motioncore CAN buses

    • 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:

      • ”can_s1” on Systemcore

      • ”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

classmethod systemcore(canbus: int, hoot_filepath: str | None = None) Self

Creates a new CAN bus for one of the native Systemcore buses.

The 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.

For the Motioncore CAN buses, use CANBus.motioncore(int, str | None) instead.

Parameters:
  • canbus (int) – Index of the Systemcore bus, from 0-4

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

Returns:

A native Systemcore CAN bus

Return type:

CANBus

classmethod motioncore(port: int, hoot_filepath: str | None = None) Self

Creates a new CAN bus for one of the Motioncore ports.

The 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:
  • port (int) – The Motioncore port, from 0-19

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

Returns:

A Motioncore CAN bus

Return type:

CANBus

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