-
Notifications
You must be signed in to change notification settings - Fork 124
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
Support reporting usb interface #47
Support reporting usb interface #47
Conversation
Tested against some composite USB hardware:
Note: I don't have the hardware to test this change against MacOs. |
USB composite devices have an interface identifier that can be useful when attempting to distinguish between multiple ports owned by the same USB device. This feature adds support for an optional 'interface' member of `UsbInfo` that will be populated for USB composite devices. Errors detecting this interface information are currently conservatively converted into `None`. Signed-off-by: mlsvrts [email protected]
e91cecd
to
3bc9096
Compare
This would be very useful for me. Is there anything I can do to help this PR be merged ? I do own a mac and an USB2serial adapter. |
Windows USB serial port information relies on regular expressions when parsing the port HWID string. Break this functionality into a seperate method, so that the regex can be validated against test device strings. Additionally, rustfmt rules have been applied. Signed-off-by: mlsvrts <[email protected]>
@maeln Thanks for the bump! Lints are passing now, and I've added some tests to make the Windows regex a little less frightening, so I think linux/windows are in a good place now. If you want to run |
@mlsvrts Tested and this is what I got :) :
Seems to work fine :) |
note about the reasoning. Signed-off-by: mlsvrts <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks pretty good, thank you for the contribution!
I did try to test this out on my MacBook (x86_64, Big Sur) with an ESP-Prog connected, which has an FT2232HL onboard. I frankly know nothing about composite devices so I'm not sure if this counts as one, but it enumerates two different serial ports so I figured it was worth a shot. While the list_ports
example ran successfully the Interface
field is always empty. If this is expected behaviour please let me know. I'm not sure if I have any other devices that would work for testing.
λ cargo run --example=list_ports
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/examples/list_ports`
Found 6 ports:
/dev/cu.Bluetooth-Incoming-Port
Type: Bluetooth
/dev/tty.Bluetooth-Incoming-Port
Type: Bluetooth
/dev/cu.usbserial-14400
Type: USB
VID:0403 PID:6010
Serial Number:
Manufacturer: FTDI
Product: Dual RS232-HS
Interface:
/dev/tty.usbserial-14400
Type: USB
VID:0403 PID:6010
Serial Number:
Manufacturer: FTDI
Product: Dual RS232-HS
Interface:
/dev/cu.usbserial-14401
Type: USB
VID:0403 PID:6010
Serial Number:
Manufacturer: FTDI
Product: Dual RS232-HS
Interface:
/dev/tty.usbserial-14401
Type: USB
VID:0403 PID:6010
Serial Number:
Manufacturer: FTDI
Product: Dual RS232-HS
Interface:
@jessebraham The interface will be 'None' if the device is not a compound device, or if the interface just can't be detected for some reason. If the FTDI driver masks that this a composite USB device, then the output is correct -- but I have no idea if that is the case: Maybe we can compare with |
Location is printed and is the same for both devices when using PySerial:
|
It looks like those ports are correctly enumerating without interface information, and
Note the additional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay thank you for checking into that. I am just going to merge this, while as you stated this is not a hard confirmation that it's working on macOS it also doesn't seem to be causing any issues. Before the next release I will find a composite device and verify that it is working as expected, and apply any fixes if needed.
USB composite devices have an interface identifier that can
be useful when attempting to distinguish between multiple
ports owned by the same USB device.
This feature adds support for an optional 'interface'
member of
UsbInfo
that will be populated for USB compositedevices. Errors detecting this interface information are
currently conservatively converted into
None
.Closes #9
Signed-off-by: mlsvrts [email protected]