Package com.ctre.phoenix6
Class CANBus
java.lang.Object
com.ctre.phoenix6.CANBus
Class for getting information about an available CAN bus.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Contains status information about a CAN bus. -
Constructor Summary
ConstructorDescriptionCANBus()
Creates a new CAN bus using the default for the system: "rio" on roboRIO "can0" on Linux "*" on WindowsCreates a new CAN bus with the given name.Creates a new CAN bus with the given name, and loads an associated hoot file for replay (equivalent toHootReplay.loadFile(java.lang.String)
). -
Method Summary
Modifier and TypeMethodDescriptiongetName()
Get the name used to construct this CAN bus.Gets the status of the CAN bus, including the bus utilization and the error counters.static CANBus.CANBusStatus
Deprecated, for removal: This API element is subject to removal in a future version.The CANBus static methods are deprecated for removal in 2026.boolean
Gets whether the network is CAN FD.static boolean
isNetworkFD
(String canbus) Deprecated, for removal: This API element is subject to removal in a future version.The CANBus static methods are deprecated for removal in 2026.
-
Constructor Details
-
CANBus
Creates a new CAN bus with the given name.- Parameters:
canbus
- 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
-
CANBus
public CANBus()Creates a new CAN bus using the default for the system:- "rio" on roboRIO
- "can0" on Linux
- "*" on Windows
-
CANBus
Creates a new CAN bus with the given name, and loads an associated hoot file for replay (equivalent toHootReplay.loadFile(java.lang.String)
).Only one hoot log may be replayed at a time. As a result, 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
- 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
hootFilepath
- Path and name of the hoot file to load
-
-
Method Details
-
getName
Get the name used to construct this CAN bus.- Returns:
- Name of the CAN bus
-
isNetworkFD
Gets whether the network is CAN FD.- Returns:
- True if the network is CAN FD
-
getStatus
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).
This function refreshes and returns a cached object.
- Returns:
- Status of the CAN bus
-
isNetworkFD
Deprecated, for removal: This API element is subject to removal in a future version.The CANBus static methods are deprecated for removal in 2026. Construct a new CANBus instance and callisNetworkFD()
instead.Gets whether the network is CAN FD.- Parameters:
canbus
- Name of the CAN bus- Returns:
- True if the network is CAN FD
-
getStatus
Deprecated, for removal: This API element is subject to removal in a future version.The CANBus static methods are deprecated for removal in 2026. Construct a new CANBus instance and callgetStatus()
instead.Gets the status of the CAN bus, including the bus utilization and the error counters.This function returns a new object every call. As a result, we recommend that this is not called inside a tight loop.
- Parameters:
canbus
- Name of the CAN bus- Returns:
- Status of the CAN bus
-