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

Auto detect scale and add to scales.h #19

Open
o-k-a-y opened this issue Jul 5, 2019 · 5 comments
Open

Auto detect scale and add to scales.h #19

o-k-a-y opened this issue Jul 5, 2019 · 5 comments

Comments

@o-k-a-y
Copy link

o-k-a-y commented Jul 5, 2019

Is it possible when plugging in a new scale to add it to scales.h so there is no manual interference? Thanks!

@sanmai
Copy link
Contributor

sanmai commented Jul 6, 2019

I guess you can make a PR, what do you think? Should be as simple as this.

(I'm not a maintainer here fwiw.)

@erjiang
Copy link
Owner

erjiang commented Jul 6, 2019

Auto-detection of USB scales would mean that there'd be no need for scales.h. It's a cool idea but I don't know how to implement it right now. Specifically, I don't know how to determine which USB devices are USB scales. Open to suggestions and/or PRs.

@skylarmt
Copy link
Contributor

skylarmt commented Apr 15, 2021

This isn't really a solution for auto-detecting scales, but what if a flag were added for specifying a USB vendor and product at runtime? If the user-specified device is attached, the list in scales.h could be ignored and the user's device assumed to be a USB scale. That way if a scale isn't in scales.h this tool can still be used without recompiling.

It also occurs to me that a crude autodetection could be accomplished easily. If no USB scale is recognized, the program could prompt the user to plug in the scale, and wait for a new USB device to show up. The new device would then be assumed to be a scale. Moving the content of scales.h to a text file and parsing it at runtime would mean the program could dynamically add detected scales to the list so autodetection will only be required once. The program could check for scales.list (or whatever it would be called) in several locations, such as the working directory, /etc/usbscale, /usr/share/usbscale, et cetera. scales.list could be as simple as one USB ID per line, written like 1446:6a73.

@erjiang
Copy link
Owner

erjiang commented Apr 15, 2021

Taking in a USB vendor and product ID on the CLI sounds like a great addition.

It would be nice, of course, to figure out if there's a way to find any USB scale based on reported capability. The scale's report descriptor should contain this info, but it seems like the device needs to be unbound before it can be read and it's not realistic to unbind all your HIDs to find a scale.

@TheWaterbug
Copy link

Maybe the easiest solution would be to parse scales.h at launch, if it exists; otherwise use the internal table.

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

No branches or pull requests

5 participants