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
Nested ClassesModifier and TypeClassDescriptionstatic classContains status information about a CAN bus. -
Constructor Summary
ConstructorsConstructorDescriptionCANBus()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 TypeMethodDescriptionfinal StringgetName()Get the name used to construct this CAN bus.final CANBus.CANBusStatusGets the status of the CAN bus, including the bus utilization and the error counters.final booleanGets whether the network is CAN FD.static CANBusroboRIO()Creates a new CAN bus for the native roboRIO bus.static CANBusCreates a new CAN bus for the native roboRIO bus, and loads an associated hoot file for replay (equivalent toHootReplay.loadFile(java.lang.String)).toString()
-
Constructor Details
-
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.For the native roboRIO CAN bus, use
roboRIO()instead.- 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
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.
For the native roboRIO CAN bus, use
roboRIO(String)instead.- 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
-
roboRIO
Creates a new CAN bus for the native roboRIO bus.- Returns:
- The native roboRIO CAN bus
-
roboRIO
Creates a new CAN bus for the native roboRIO bus, 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:
hootFilepath- Path and name of the hoot file to load- Returns:
- The native roboRIO CAN bus
-
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
-
toString
-