Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hal] Add CanApitypes to java (Feature Parity) #6121

Merged
merged 5 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions hal/src/main/java/edu/wpi/first/hal/CANAPITypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// 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.
*
* <p>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.
*
* <p>This enum represents different types of CAN devices. Teams are encouraged to use the
* kMiscellaneous for custom or miscellaneous devices.
*
* @see <a
* href="https://docs.wpilib.org/en/stable/docs/software/can-devices/can-addressing.html">CAN
* Device Types</a>
*/
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);

public final int m_id;
m10653 marked this conversation as resolved.
Show resolved Hide resolved

CANDeviceType(int id) {
this.m_id = id;
}
}

/**
* FRC CAN manufacturer ID.
*
* <p>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 <a
* href="https://docs.wpilib.org/en/stable/docs/software/can-devices/can-addressing.html">CAN
* Manufacturer IDs</a>
*/
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);

public final int m_id;

CANManufacturer(int id) {
this.m_id = id;
}
}
}
5 changes: 3 additions & 2 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/CAN.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,8 +22,8 @@
* 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.m_id;
public static final int kTeamDeviceType = CANAPITypes.CANDeviceType.kMiscellaneous.m_id;

private final int m_handle;

Expand Down