-
Notifications
You must be signed in to change notification settings - Fork 437
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
Use the usb description for CP board name #2327
base: master
Are you sure you want to change the base?
Conversation
It appears this is the product name on Linux at least.
Thanks for the PR @tannewt! PR #2323 has been merged, so rebasing or merging main should resolve the CI failures. Has this been tested in Windows and macOS? Looks like the default value for Another thing to keep in mind is that |
It's not Stock
I tested on all three OS's. I see that Stock (transcripts below are a bit elided and don't show me tracking down the correct port index from multiple ports) Ubuntu 22.04 # adafruit_board_toolkit works
>>> import adafruit_board_toolkit.circuitpython_serial
>>> ports = adafruit_board_toolkit.circuitpython_serial.comports()
>>> ports[0].interface
'CircuitPython CDC control'
>>> ports[0].description
'Metro M4 Express - CircuitPython CDC control'
# pyserial works
>>> import serial
>>> import serial.tools.list_ports
>>> ports = serial.tools.list_ports.comports()
>>> ports[2].interface
'CircuitPython CDC control'
>>> ports[2].description
'Metro M4 Express - CircuitPython CDC control' macOS 12.5 on an Intel machine # adafruit_board_toolkit works
>>> import adafruit_board_toolkit.circuitpython_serial
>>> ports = adafruit_board_toolkit.circuitpython_serial.comports()
>>> ports[0].interface
'CircuitPython CDC data'
>>> ports[0].description
'Metro M4 Express - CircuitPython CDC data'
# pyserial works now (didn't used to)
>>> import serial.tools.list_ports
>>> ports = serial.tools.list_ports.comports()
>>> ports[0].interface
'CircuitPython CDC data'
>>> ports[0].description
'Metro M4 Express - CircuitPython CDC data' Windows 10 21H2 # Windows substitutes its own description
>>> import adafruit_board_toolkit.circuitpython_serial
>>> ports =adafruit_board_toolkit.circuitpython_serial.comports()
>>> ports[0].interface
'CircuitPython CDC control'
>>> ports[0].description
'USB Serial Device (COM8)'
# pyserial can't get interface and gives its own description
>>> import serial
>>> import serial.tools.list_ports
>>> ports = serial.tools.list_ports.comports()
>>> ports[1].interface
>>> ports[1].description
'USB Serial Device (COM8)' |
I think it would be better to use On windows the product is missing, and the description is generic garbage (but localized !)
In discotool I found that the WMI interface truncates the USB product field (to 16 characters I think - think of the |
So rather than Would something like this work? |
My last message went almost at the same time as @Neradoc's, and that responds to some of these questions, thanks! Oh and thanks @dhalbert for the details info before as well! So even with the If that's the case, do we know if there is any other way to retrieve the name from a different USB property or with some ctypes workaround? |
I believe I tried to add the product to the pyserial code by poking around with ctypes where it gets the description, and failed, but then again I don't know those APIs. My conclusion was that the APIs used by pyserial only relate to COM ports and don't have that information, so other APIs have to be used. The fact that the USB name is not available in Device Manager seemed to confirm that. So I found that code that uses |
I only tested on Arch Linux. This serial info isn't coming from pyserial directly. It is a QSerialPortInfo. The description for me and my test board is "ESP32-S3-USB-OTG-N8" and does not contain the interface name. |
@dhalbert Please finish this for me. |
Love this. Great delegation there @tannewt. 😛 I think you missed Big hugs to all Adafruits in this chat, and many thanks for your continued contributions and support. |
adafruit/Adafruit_Board_Toolkit#11 explains how you could get the proper |
It appears this is the product name on Linux at least.