Class CANBuses
java.lang.Object
swervelib.core.parser.CANBuses
Turns the
canbus of a device in the JSON configuration into a CAN bus, the same way for every vendor.
- Empty: the Systemcore CAN bus
can_s0. - A bus number:
"0"to"4"are the Systemcore CAN busescan_s0tocan_s4, so"1"iscan_s1."5"to"24"are the Motioncore CAN busescan_d0tocan_d19, followingCANPort. - Anything else is a vendor specific CAN bus, such as the name of a CANivore for CTRE devices. Vendors that only use the Systemcore and Motioncore CAN buses reject it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.wpilib.hardware.bus.CANPortCAN bus used when a device leavescanbusempty. -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<org.wpilib.hardware.bus.CANPort> getCANPort(String canbus) Get theCANPortfor thecanbusof a device.static org.wpilib.hardware.bus.CANPortrequireCANPort(String canbus, String vendor) Get theCANPortfor thecanbusof a device from a vendor that only uses the Systemcore and Motioncore CAN buses.
-
Field Details
-
DEFAULT
public static final org.wpilib.hardware.bus.CANPort DEFAULTCAN bus used when a device leavescanbusempty.
-
-
Method Details
-
getCANPort
Get theCANPortfor thecanbusof a device.- Parameters:
canbus-canbusfrom the JSON configuration.- Returns:
- The
CANPort, or empty whencanbusnames a vendor specific CAN bus. - Throws:
IllegalArgumentException- ifcanbusis a bus number that is not aCANPort.
-
requireCANPort
Get theCANPortfor thecanbusof a device from a vendor that only uses the Systemcore and Motioncore CAN buses.- Parameters:
canbus-canbusfrom the JSON configuration.vendor- Vendor name, for the error message.- Returns:
- The
CANPort. - Throws:
IllegalArgumentException- ifcanbusis not a Systemcore or Motioncore CAN bus number.
-