Class CANBus

java.lang.Object
com.ctre.phoenix6.CANBus

public class CANBus extends Object
Class for getting information about an available CAN bus.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Contains status information about a CAN bus.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new CAN bus using the default for the system: "rio" on roboRIO "can0" on Linux "*" on Windows
    CANBus(String canbus)
    Creates a new CAN bus with the given name.
    CANBus(String canbus, String hootFilepath)
    Creates a new CAN bus with the given name, and loads an associated hoot file for replay (equivalent to HootReplay.loadFile(java.lang.String)).
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the name used to construct this CAN bus.
    Gets the status of the CAN bus, including the bus utilization and the error counters.
    getStatus(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.
    boolean
    Gets whether the network is CAN FD.
    static boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    The CANBus static methods are deprecated for removal in 2026.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CANBus

      public CANBus(String 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

      public CANBus(String canbus, String hootFilepath)
      Creates a new CAN bus with the given name, and loads an associated hoot file for replay (equivalent to HootReplay.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

      public String getName()
      Get the name used to construct this CAN bus.
      Returns:
      Name of the CAN bus
    • isNetworkFD

      public 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).

      This function refreshes and returns a cached object.

      Returns:
      Status of the CAN bus
    • isNetworkFD

      @Deprecated(forRemoval=true) public 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. Construct a new CANBus instance and call isNetworkFD() 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 call getStatus() 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