fix(usbtools): Handle Missing LangID in UsbTools.get_string()#415
Open
sebm95 wants to merge 1 commit into
Open
fix(usbtools): Handle Missing LangID in UsbTools.get_string()#415sebm95 wants to merge 1 commit into
sebm95 wants to merge 1 commit into
Conversation
Owner
|
Cross checking: it addresses a situation where with multiple FTDI devices are connected and at least one has no access permission, the enumeration fails for all of them, right? What about on attempting to open (not only listing) the FTDI device that has no permission with this patch? What error is actually reported in this case? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue:
When multiple FTDI devices are connected, such as a custom FTDI-based board alongside an ESP32 debugger, the debugger can cause USB enumeration failures due to missing or inaccessible language IDs (LangIDs). Specifically, when these LangIDs are missing, calling
UsbTools.get_string()raises aValueError. This impacts critical functions including:and any other method relying on USB device enumeration.
Fix:
This PR modifies
UsbTools.get_string()to gracefully handle cases where LangIDs are missing. Instead of raising an exception, it catches the ValueError and returns an empty string. This prevents enumeration-related crashes and significantly improves compatibility with setups containing mixed FTDI devices, such as those involving ESP debuggers.Additional Notes:
On Linux environments or Docker setups, proper udev rules might mitigate the issue. However, this fix enhances compatibility across Windows and macOS as well.
Impact:
Prevents crashes during USB enumeration.
Ensures smoother operation when ESP debuggers or similar devices with incomplete USB descriptors are connected.
Enhances overall robustness of pyftdi in diverse hardware environments.
Related Issues:
Potentially resolves issues reported in #358 and #311.