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.static enumPossible states of the CAN bus. -
Constructor Summary
ConstructorsConstructorDescriptionCANBus()Creates a new CAN bus using the default for the system: "can_s2" on Systemcore "can0" on Linux "*" on WindowsCreates a new CAN bus with the given name.Creates a new CAN bus for one of the native Systemcore/Motioncore buses. -
Method Summary
Modifier and TypeMethodDescriptionclone()intCompares the two CAN bus names.booleanfinal StringgetName()Get the name used to construct this CAN bus.final MemorySegmentGet the name used to construct this CAN bus as 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.toString()
-
Constructor Details
-
CANBus
public CANBus()Creates a new CAN bus using the default for the system:- "can_s2" on Systemcore
- "can0" on Linux
- "*" on Windows
-
CANBus
Creates a new CAN bus with the given name.For the native Systemcore/Motioncore CAN buses, use
CANBus(CANPort)instead.- Parameters:
canbus- 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
-
CANBus
Creates a new CAN bus for one of the native Systemcore/Motioncore buses.For the CANivore and non-FRC SocketCAN interfaces, use
CANBus(String)instead.- Parameters:
canPort- The Systemcore/Motioncore CAN port
-
-
Method Details
-
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 UTF-8 bytes, including null termination. This is only used for FFI; robot code should callgetName()instead.- Returns:
- Name of the CAN bus as UTF-8 bytes
-
isNetworkFD
public final boolean 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).
- 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
-