Class CanBuses

java.lang.Object
frc.spectrumLib.hardware.CanBuses

public final class CanBuses extends Object
The CAN buses FM runs on under SystemCore, and the one place a bus name becomes a CANBus.

On the 2026 roboRIO FM had two buses: a CANivore ("*") carrying the drivetrain and most mechanisms, and the roboRIO's own bus ("rio") carrying the intake rollers. SystemCore has no "rio" bus; it has five native CAN FD ports, addressed with CANBus.systemcore(int). A CANivore still works on SystemCore once CTRE's canivore-usb package is installed on it (see wpilibsuite/SystemcoreTesting CTR-Phoenix.md), so the CANivore half of the robot keeps its wiring and only the roboRIO-bus devices move.

Device configs keep carrying bus names (strings) as they did in 2026. forName(String) resolves SYSTEMCORE_PREFIXn to CANBus.systemcore(n) and anything else to a CANivore by name.

Check against the wiring before the event: USE_CANIVORE and the port of each group.

  • Field Details

    • SYSTEMCORE_PREFIX

      public static final String SYSTEMCORE_PREFIX
      Prefix for a SystemCore native port, e.g. "systemcore:0".
      See Also:
    • USE_CANIVORE

      public static final boolean USE_CANIVORE
      Whether FM runs its CANivore. true is the 2026 wiring: drivetrain and most mechanisms on the CANivore, intake rollers on SystemCore port 0. false spreads everything over the SystemCore's native ports instead (see DRIVETRAIN, SHOOTER, MECHANISMS); no "*" bus is ever opened.
      See Also:
    • CANIVORE

      public static final String CANIVORE
      The first CANivore found.
      See Also:
    • RIO_CANBUS

      public static final String RIO_CANBUS
      Where the devices that were on the roboRIO's own CAN bus in 2026 (the intake rollers) now live: SystemCore CAN port 0.
      See Also:
    • DRIVETRAIN

      public static final String DRIVETRAIN
      Swerve: 8 TalonFX, 4 CANcoders and the Pigeon. Without the CANivore it gets a port to itself, for the 250 Hz odometry signals.
      See Also:
    • SHOOTER

      public static final String SHOOTER
      Launcher (4 TalonFX) and hood.
      See Also:
    • MECHANISMS

      public static final String MECHANISMS
      Intake extension, indexer bed, indexer tower and the CANdle.
      See Also:
  • Method Details

    • inUse

      public static Map<String,String> inUse()
      The buses this layout uses, by the name their health is logged under ( <label>/StatusOK, <label>/BusUtilization, ...).
      Returns:
      label to bus name, in port order
    • label

      public static String label(String name)
      The label a bus's health is logged under (inUse()), for messages.
      Parameters:
      name - a bus name from a config
      Returns:
      its label, or the name itself if this layout does not use it
    • forName

      public static CANBus forName(String name)
      Resolves a bus name from a config into a Phoenix CANBus.
      Parameters:
      name - "systemcore:n" for a native SystemCore port, else a CANivore name
      Returns:
      the bus
    • forName

      public static CANBus forName(String name, String hootPath)
      Resolves a bus name into a Phoenix CANBus that also records a hoot log.
      Parameters:
      name - "systemcore:n" for a native SystemCore port, else a CANivore name
      hootPath - hoot log path, or empty for none
      Returns:
      the bus