u2if icon indicating copy to clipboard operation
u2if copied to clipboard

Multiple retries may be necessary

Open lesamouraipourpre opened this issue 4 years ago • 0 comments

While testing U2IF I've noticed that it sometimes takes more than one try to connect to the device:

>>> dev = machine.Device()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/projects/u2if/.env/lib/python3.7/site-packages/source/machine/helper.py", line 9, in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
  File "/mnt/projects/u2if/.env/lib/python3.7/site-packages/source/machine/u2if.py", line 22, in __init__
    raise ValueError("No board found")
ValueError: No board found
>>> dev = machine.Device()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/projects/u2if/.env/lib/python3.7/site-packages/source/machine/helper.py", line 9, in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
  File "/mnt/projects/u2if/.env/lib/python3.7/site-packages/source/machine/u2if.py", line 22, in __init__
    raise ValueError("No board found")
ValueError: No board found
>>> dev = machine.Device()
>>> dev.firmware_version
[0, 5, 0]
>>> dev.vid
51966
>>> dev.pid
16389

In the example above it took 3 attempts to connect to a RP2040 Pico. Given that the hid library seems to only return null/None with no apparent errors thrown would it be possible to add some kind of connection retry mechanism?

lesamouraipourpre avatar Jun 29 '21 16:06 lesamouraipourpre