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

Where is HID_::getShortName called from? #20

Closed
forderud opened this issue Sep 9, 2024 · 1 comment · Fixed by #21
Closed

Where is HID_::getShortName called from? #20

forderud opened this issue Sep 9, 2024 · 1 comment · Fixed by #21

Comments

@forderud
Copy link
Contributor

forderud commented Sep 9, 2024

I see that the UPS.ino sample contain a const char STRING_SERIAL[] PROGMEM = "UPS10" string that is correctly picked up as BatterySerialNumber in Windows. This seem to work in practice, but I'm struggling to understand why & how it works.

The only place where STRING_SERIAL string is accessed is in the PowerDevice.setSerial(STRING_SERIAL) call that assigns the string to HID_::serial. The HID_::serial pointer is furthermore only read & returned from HID_::getShortName. The weird thing is that the HID_::getShortName method appears to be dead code that is not called from anywhere. Still, the STRING_SERIAL string still somehow manages to be propagated to Windows, which seems like a mystery to me. Modifying HID_::getShortName will also change the battery serial number reported by Windows.

Is the HID_::getShortName method automatically called by some external Arduino code, or is there some other mechanism in play here that I don't understand?

forderud added a commit to forderud/HIDPowerDevice that referenced this issue Sep 9, 2024
Fixes abratchik#20. Done to make it clear that these virtual methods are defined in the PluggableUSBModule base-class and might be called from external code not seen in this repo.
@forderud
Copy link
Contributor Author

forderud commented Sep 9, 2024

Answering my own question with #21 that explicitly annotates getShortName and the other virtual methods with override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant