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] Change usage reporting to string-based #7763

Open
wants to merge 1 commit into
base: 2027
Choose a base branch
from

Conversation

PeterJohnson
Copy link
Member

@PeterJohnson PeterJohnson commented Feb 4, 2025

TODO:

  • Add documentation for usage conventions
    • Semi-standardize naming of things; vendor namespacing; brackets approach; how to handle multiple inputs (Encoders) or things within CAN devices; what should be in the name vs the value (names must be unique, values overwrite for the same name). For example, should it be Solenoid[ID][Num] with a value of PCM or PCM[ID]/Solenoid[Num] with an empty value? The latter avoids the potential conflict of having both a PCM and a PH on the same ID.
    • Should the data string always be specified to be JSON? Note we'll still have to handle the case if it isn't, so maybe just a recommendation for complex data.
  • Change CameraServerShared to generic reporting as well
  • Cleanup formatting

Fixes #301.

@PeterJohnson PeterJohnson requested review from a team as code owners February 4, 2025 06:37
Copy link
Contributor

github-actions bot commented Feb 4, 2025

This PR modifies commands. Please open a corresponding PR in Python Commands and include a link to this PR.

@github-actions github-actions bot added component: wpilibj WPILib Java component: wpilibc WPILib C++ component: hal Hardware Abstraction Layer component: command-based WPILib Command Based Library component: wpimath Math library 2027 2027 target labels Feb 4, 2025
@sciencewhiz
Copy link
Contributor

Fixes #301

Copy link
Contributor

@KangarooKoala KangarooKoala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a mix of adding one to the port and not adding one to the port? (Notably, AnalogAccerelometer and DigitalInput have different behavior depending on the language)

Files that started adding one: None
Files that still add one: hid.lang.jinja, pwm_motor_controller.lang.jinja, AnalogAccelerometer.cpp, DigitalInput.cpp
Files that never added one: ADXL345_I2C.java (didn't report port before), I2C.lang (used to report just device address, now also reports port), PowerDistribution.lang (didn't port module before), UpDownCounter.java
Files that no longer add one: AddressableLED.lang, AnalogAccelerometer.java, AnalogGyro.java, CAN.lang, Compressor.lang, DigitalInput.java, DigitalOutput.lang, DoubleSolenoid.lang, DutyCycle.lang, Encoder.lang (part of changing from using FPGA index to using a and b channels), Joystick.lang, PWM.lang, SerialPort.lang, Servo.lang, Solenoid.lang, Tachometer.lang, UpDownCounter.cpp, NidecBrushless.lang

Comment on lines +227 to +228
connInfo->remote_id.starts_with("elastic") ||
connInfo->remote_id.starts_with("Elastic") ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor- Do we care about Elastic having two different names it might be reported as? (Since right now the remote id is directly reported)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was to cover people using 2024 Elastic, I think it's safe to get rid of the special case for 2027.

@@ -45,7 +44,7 @@ public NidecBrushless(final int pwmChannel, final int dioChannel) {
m_pwm = new PWM(pwmChannel);
SendableRegistry.addChild(this, m_pwm);

HAL.report(tResourceType.kResourceType_NidecBrushless, pwmChannel + 1);
HAL.reportUsage("NidecBrushless", pwmChannel, "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this report dioChannel like C++ does?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2027 2027 target component: command-based WPILib Command Based Library component: hal Hardware Abstraction Layer component: wpilibc WPILib C++ component: wpilibj WPILib Java component: wpimath Math library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants