diff --git a/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java b/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java new file mode 100644 index 0000000000..903cd9bd54 --- /dev/null +++ b/hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java @@ -0,0 +1,83 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package edu.wpi.first.hal; + +/** + * CAN API Types. + * + *
This class defines enums for CAN device types and manufacturer IDs as specified in the WPILib + * documentation: https://docs.wpilib.org/en/stable/docs/software/can-devices/can-addressing.html + */ +public class CANAPITypes { + /** + * FRC CAN device type. + * + *
This enum represents different types of CAN devices. Teams are encouraged to use the + * kMiscellaneous for custom or miscellaneous devices. + * + * @see CAN + * Device Types + */ + public enum CANDeviceType { + kBroadcast(0), + kRobotController(1), + kMotorController(2), + kRelayController(3), + kGyroSensor(4), + kAccelerometer(5), + kUltrasonicSensor(6), + kGearToothSensor(7), + kPowerDistribution(8), + kPneumatics(9), + kMiscellaneous(10), + kIOBreakout(11), + kFirmwareUpdate(31); + + @SuppressWarnings("PMD.MemberName") + public final int id; + + CANDeviceType(int id) { + this.id = id; + } + } + + /** + * FRC CAN manufacturer ID. + * + *
This enum represents different manufacturer IDs for CAN devices. Teams are encouraged to use + * the kTeamUse manufacturer ID for custom or team-specific devices. + * + * @see CAN + * Manufacturer IDs + */ + public enum CANManufacturer { + kBroadcast(0), + kNI(1), + kLM(2), + kDEKA(3), + kCTRE(4), + kREV(5), + kGrapple(6), + kMS(7), + kTeamUse(8), + kKauaiLabs(9), + kCopperforge(10), + kPWF(11), + kStudica(12), + kTheThriftyBot(13), + kReduxRobotics(14), + kAndyMark(15), + kVividHosting(16); + + @SuppressWarnings("PMD.MemberName") + public final int id; + + CANManufacturer(int id) { + this.id = id; + } + } +} diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java index 8808a4b68b..0f94e35112 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java @@ -5,6 +5,7 @@ package edu.wpi.first.wpilibj; import edu.wpi.first.hal.CANAPIJNI; +import edu.wpi.first.hal.CANAPITypes; import edu.wpi.first.hal.CANData; import edu.wpi.first.hal.FRCNetComm.tResourceType; import edu.wpi.first.hal.HAL; @@ -21,8 +22,8 @@ import java.io.Closeable; * calls. */ public class CAN implements Closeable { - public static final int kTeamManufacturer = 8; - public static final int kTeamDeviceType = 10; + public static final int kTeamManufacturer = CANAPITypes.CANManufacturer.kTeamUse.id; + public static final int kTeamDeviceType = CANAPITypes.CANDeviceType.kMiscellaneous.id; private final int m_handle;