Package com.ctre.phoenix6
Class CANBus
java.lang.Object
com.ctre.phoenix6.CANBus
- All Implemented Interfaces:
Cloneable,Comparable<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 TypeMethodDescriptionclone()intCompares the two CAN bus names.booleanfinal StringgetName()Get the name used to construct this CAN bus.final ByteBufferGet the name used to construct this CAN bus as raw UTF-8 bytes, including null termination.final CANBus.CANBusStatusGets the status of the CAN bus, including the bus utilization and the error counters.inthashCode()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
-
getNameUTF8Bytes
Get the name used to construct this CAN bus as raw UTF-8 bytes, including null termination. This is only used for JNI; robot code should callgetName()instead.- Returns:
- Name of the CAN bus as a raw UTF-8 byte buffer
-
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
-
equals
-
hashCode
-
clone
-
compareTo
Compares the two CAN bus names.- Specified by:
compareToin interfaceComparable<CANBus>- Parameters:
other- The CANBus to be compared- Returns:
- The result of calling
String.compareTo(String)on the names of the two CAN buses
-