mbed-tools
mbed-tools copied to clipboard
Running `mbed-tools detect` on mac_os fails when a USB peripheral does not provide some data
Describe the bug
Running mbed-tools detect on mac_os fails when a USB peripheral (i.e. my USB mouse) does not provide some data (in my case, there is no vendor_id in the USB device properties)
To Reproduce Steps to reproduce the behavior:
- plug a USB device providing no
vendor_id(for example, verify which info are provided by USB peripherals by runningsystem_profiler SPUSBDataType) - run
mbed-tools detect - the script crashes reporting
IndexError: list index out of range
Expected behavior
mbed-tools detect should discard the USB peripheral with missing info, if they are necessary to detect the board, instead of throwing an error
Desktop (please complete the following information):
- OS: mac_os
- Version: 12.6.5
Mbed (please complete the following information):
- Device: no device (issue independent from the connected device)
- Mbed OS Version: 6.17.0
- Mbed CLI 2 Version: 7.59.0
Additional context
in file mbed_tools/devices/_internal/darwin/device_detector.py
in function _assemble_candidate_data
the line device_data.get("vendor_id", "") produces a crash when the vendor_id is not provided by the peripheral
(I expect the same possible issue with the next two lines, using the same method to get "product_id" and "serial_num")
Traceback (most recent call last):
File "/myProject/bin/mbed-tools", line 8, in