phoenix6.canbus¶
Module Contents¶
Attributes¶
- phoenix6.canbus.USE_WPILIB = 'True'¶
- class phoenix6.canbus.CANState¶
Bases:
enum.EnumPossible states of the CAN bus.
- ERROR_ACTIVE = '0'¶
The controller is in normal operation.
- ERROR_WARNING = '1'¶
The controller has detected errors and is approaching the Error Passive state.
- ERROR_PASSIVE = '2'¶
The controller is in the “Error Passive” state and has detected many errors.
- BUS_OFF = '3'¶
The controller is in the “Bus Off” state after detecting too many errors.
- STOPPED = '4'¶
The controller has been manually stopped.
- SLEEPING = '5'¶
The controller has entered low-power sleep mode.
- 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
- bus_error_count: int = '0'¶
Bus error count
- arbitration_lost_count: int = '0'¶
Arbitration lost count
- restart_count: int = '0'¶
Restart count
- tx_full_count: int = '0'¶
Transmit buffer full count
- rec: int = '0'¶
Receive Error Counter (REC)
- tec: int = '0'¶
Transmit Error Counter (TEC)
- WPIStruct¶
- class phoenix6.canbus.CANBus(canbus: str = '', /)¶
- class phoenix6.canbus.CANBus(can_port: wpilib.CANPort, /)
Class for getting information about an available CAN bus.
Overloaded function.
Creates a new CAN bus with the given name.
For the native Systemcore/Motioncore CAN buses, use CANBus(CANPort) instead.
- Parameters:
canbus (str, optional) –
Name of the CAN bus. Possible CAN bus strings are:
”can_s0” to “can_s4” for the native Systemcore CAN buses
”can_d0” to “can_d19” for the 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_s2” on Systemcore
”can0” on Linux
”*” on Windows
Creates a new CAN bus for one of the native Systemcore/Motioncore buses.
For the CANivore and non-FRC SocketCAN interfaces, use CANBus(str) instead.
- Parameters:
can_port (CANPort) – The Systemcore/Motioncore CAN port
- 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: