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

device.hardware.py: Add skip_on_error flag to improve Windows experience with USB discovery #545

Merged
merged 1 commit into from Mar 28, 2024

Conversation

colinoflynn
Copy link
Contributor

If any of the USB devices attached are busy or unavailable, but libusb1 sees them, you get a nice trace on Windows:

$ glasgow list
Traceback (most recent call last):
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\WPy64-31080\python-3.10.8.amd64\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\WPy64-31080\python-3.10.8.amd64\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\users\c_ofl\.local\bin\glasgow.exe\__main__.py", line 7, in <module>
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\chipwhisperer\jupyter\user\glasgow\glasgow\software\glasgow\cli.py", line 937, in main
    exit(loop.run_until_complete(_main()))
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\WPy64-31080\python-3.10.8.amd64\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\chipwhisperer\jupyter\user\glasgow\glasgow\software\glasgow\cli.py", line 900, in _main
    for serial in sorted(GlasgowHardwareDevice.enumerate_serials()):
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\chipwhisperer\jupyter\user\glasgow\glasgow\software\glasgow\device\hardware.py", line 195, in enumerate_serials
    devices = cls._enumerate_devices(usb_context)
  File "C:\ChipWhisperer5_64_5_7_0\cw\home\portable\chipwhisperer\jupyter\user\glasgow\glasgow\software\glasgow\device\hardware.py", line 99, in _enumerate_devices
    devices.extend(list(usb_context.getDeviceIterator()))
  File "C:\Users\c_ofl\AppData\Local\pipx\pipx\venvs\glasgow\lib\site-packages\usb1\__init__.py", line 2114, in wrapper
    for value in generator:
  File "C:\Users\c_ofl\AppData\Local\pipx\pipx\venvs\glasgow\lib\site-packages\usb1\__init__.py", line 2257, in getDeviceIterator
    device = USBDevice(
  File "C:\Users\c_ofl\AppData\Local\pipx\pipx\venvs\glasgow\lib\site-packages\usb1\__init__.py", line 1784, in __init__
    mayRaiseUSBError(result)
  File "C:\Users\c_ofl\AppData\Local\pipx\pipx\venvs\glasgow\lib\site-packages\usb1\__init__.py", line 127, in mayRaiseUSBError
    __raiseUSBError(value)
  File "C:\Users\c_ofl\AppData\Local\pipx\pipx\venvs\glasgow\lib\site-packages\usb1\__init__.py", line 119, in raiseUSBError
    raise __STATUS_TO_EXCEPTION_DICT.get(value, __USBError)(value)
usb1.USBErrorIO: LIBUSB_ERROR_IO [-1]

With this patch you instead get what you expect:

$ glasgow list
C3-20240303T140525Z

This was something we have added to ChipWhisperer's USB discovery code, you can see here if useful!

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@whitequark
Copy link
Member

Could you change the commit message please to remove the .py suffix?

@colinoflynn
Copy link
Contributor Author

I think the force-push fixed that, lmk if not. Thanks!

Copy link
Member

@whitequark whitequark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@whitequark whitequark added this pull request to the merge queue Mar 28, 2024
Merged via the queue into GlasgowEmbedded:main with commit cad5fa4 Mar 28, 2024
20 checks passed
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.

None yet

2 participants