adafruit / adafruit/Adafruit_CircuitPython_USB_Host_Descriptors
MemoryError while trying to display device.manufacturer or device.product.
- Dominant language
- Python
- Stars
- 1
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
I tested up to 10 differents USB devices without problem.
But one of my device is resisiting and crashing with a MemoryError when trying to display:
device.manufacturer
and when trying to display:
device.product
Not sure what is going on, but there is something wrong.
```
searching for devices
pid 0x2303
vid 0x67b
Traceback (most recent call last):
File "code.py", line 18, in
MemoryError: memory allocation failed, allocating 2147483647 bytes
Code done running.
```
The offending line is line 18, but if I comment out that line, I have the same error and memory allocation for line 19.
```
print("pid", hex(device.idProduct))
print("vid", hex(device.idVendor))
# print("man", device.manufacturer)
# print("product", device.product)
print("serial", device.serial_number)
print("config[0]:")
```
Only if I remove both line like above, can I get some proper output:
```
Code stopped by auto-reload. Reloading soon.
soft reboot
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
searching for devices
pid 0x2303
vid 0x67b
serial None
config[0]:
value 1
interface[0]
class ff subclass 00
IN 81
OUT 02
IN 83
Code stopped by auto-reload. Reloading soon.
soft reboot
```
Notice that the code stop and restart in loop.
This is not consistent with the usual waiting loop that is more like this:
```
searching for devices
searching for devices
searching for devices
```
When plugging that same device in my Linux, it behave well and we can see the manufacturer and product:
```
[46203.061185] usb 3-3: new full-speed USB device number 34 using xhci_hcd
[46203.209942] usb 3-3: New USB device found, idVendor=067b, idProduct=2303, bcdDevice= 4.00
[46203.209957] usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[46203.209963] usb 3-3: Product: USB-Serial Controller D
[46203.209967] usb 3-3: Manufacturer: Prolific Technology Inc.
[46203.236186] usbcore: registered new interface driver usbserial_generic
[46203.236203] usbserial: USB Serial support registered for generic
[46203.239716] usbcore: registered new interface driver pl2303
[46203.239731] usbserial: USB Serial support registered for pl2303
[46203.239749] pl2303 3-3:1.0: pl2303 converter detected
[46203.241740] usb 3-3: pl2303 converter now attached to ttyUSB0
```
CP displayed without problem another `Prolific Technology Inc.` device "USB to Parallel" but was not happy with my "USB to Serial". It worked also with another USB to Serial that was not from Prolific.
So it is a problem just with one particular device.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the failure with the Prolific USB-to-Serial device using the shown code.py and compare access to device.manufacturer and device.product with the devices that work. Inspect the descriptor access that triggers the 2147483647-byte allocation; done means those properties no longer crash or restart the device and still report the available descriptor values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100