Class CANcoder

All Implemented Interfaces:
CommonDevice, Sendable, AutoCloseable

public class CANcoder extends CoreCANcoder implements Sendable, AutoCloseable
WPILib-integrated version of CoreCANcoder.
  • Constructor Details

    • CANcoder

      public CANcoder(int deviceId)
      Constructs a new CANcoder object.

      Constructs the device using the default CAN bus for the system (see CANBus()).

      Parameters:
      deviceId - ID of the device, as configured in Phoenix Tuner
    • CANcoder

      @Deprecated(since="2026", forRemoval=true) public CANcoder(int deviceId, String canbus)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead.
      Constructs a new CANcoder object.
      Parameters:
      deviceId - ID of the device, as configured in Phoenix Tuner
      canbus - Name of the CAN bus this device is on. 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
    • CANcoder

      public CANcoder(int deviceId, CANBus canbus)
      Constructs a new CANcoder object.
      Parameters:
      deviceId - ID of the device, as configured in Phoenix Tuner
      canbus - The CAN bus this device is on
  • Method Details

    • none

      public static CANcoder none()
      Constructs a stubbed-out CANcoder, where all status signals, controls, configs, etc. perform no action and immediately return OK. This can be used to silence error messages for devices that have been completely removed from the robot.
      Returns:
      Stubbed-out CANcoder
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • initSendable

      public void initSendable(SendableBuilder builder)
      Specified by:
      initSendable in interface Sendable