Skip to content

Conversation

@sebm95
Copy link

@sebm95 sebm95 commented May 27, 2025

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 a ValueError. This impacts critical functions including:

Ftdi.list_devices()

Ftdi.open_from_url()

serialext.serial_for_url()

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.

@sebm95 sebm95 changed the title fix(usbtools): Handle Missing LangID in UsbTools.get_string() caused during device enumeration fix(usbtools): Handle Missing LangID in UsbTools.get_string() May 27, 2025
@eblot
Copy link
Owner

eblot commented Aug 14, 2025

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?

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 this pull request may close these issues.

2 participants