-
Notifications
You must be signed in to change notification settings - Fork 78
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
multi-language STRING Desc support #122
multi-language STRING Desc support #122
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really cool. Glad to see we're adding support for non-English language :)
Some minor feedback requested to make this more robust
Cross check the list length between `extra_lang_ids`, `manufacturer`, `product` and `serial_number` on constructing `UsbDeviceBuilder`. Build `lang_id_bytes` with rust iterators in `descriptor_type::STRING` of `fn get_descriptor()`. A quick impl `LangID` enum.
hi, I have do some modifications. |
Replace `u16` to `LangID` impl with `num_enum::TryFromPrimitive`. Add `defmt` formatter for `LangID`. Reject any requests that asking lang_ids which is not supported by device.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking really good - one last request
Co-authored-by: Ryan Summers <[email protected]>
hi, I still got a few concerns.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it wouldn't be simpler/less costly to check that EN_US
is part of the custom lang_ids
list at the time it is set, rather than having constructs like [LangID::EN_US].iter().chain(extra_lang_ids.iter())
.
See: https://github.com/eZioPan/usb-device/compare/multi-language-support...ithinuel:usb-device:PR122
Hi @ithinuel , thanks for the work. I think it's a good solution. Let see what @ryan-summers will say about this. And I will sugguest to ensure that |
A modified my proposal to check |
@ithinuel it looks really cool. I have test on my device, and find that there could be a minor bug. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if we just got the groundwork in here, and maybe @ithinuel wants to follow-up with a new PR with their improvements? :)
Thanks to both of you for the great work on this!
I have reverse the change, keep 16 lang_ids limitation. |
Please do - if this is the case, I'm less concerned about the overall "correctness" of the various lang IDs - if people hit issues, they can submit PRs to fix it, I don't see a huge risk in a slightly incorrect lang ID outside of potentially failing to enumerate properly on some PC dialects, but given that lang ID is deprecated, I imagine this will go away in the future anyways.
No, as long as LangID is publicly accessible from the crate. |
If you want to add documentation to LangID, feel free. If not, I'll merge as-is in a little while. In general, I think we could use a rewrite of the builder to be something like |
Thanks, I would ask a merge. I'm afraid that I'm not very good at English, so maybe I just leave it. |
I understand :) Thanks a lot for working on this! It's been greatly appreciated |
add a
extra_lang_ids: Option<&'a [u16]>
extra_lang_ids: Option<&'a [LangID]>
tostruct Config
to store LANGIDs.extend
descriptor_type::STRING
branch offn get_descriptor()
, so that it will send all support LANGID in first STRING Desc, and try responding every STRING Request with matched LANGID.add a
.extra_lang_ids()
.set_extra_lang_ids()
method toUsbDeviceBuilder
, which will take a&[u16]
&[LangID]
to add extra support LANGID.Breaking
UsbDeviceBuilder::manufacturer()
UsbDeviceBuilder::product()
UsbDeviceBuilder::serial_number()
will ask a&[&str]
as input, first&str
in&[&str]
will match English lang, the rest will match what have been put into.extra_lang_ids()
.set_extra_lang_ids()
.