Skip to content
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

Try find port type in parent device #170

Merged
merged 5 commits into from
Jul 25, 2024
Merged

Conversation

soiamsoNG
Copy link
Contributor

for docker enviroment udev not run well for device add by --device
without ID_BUS like ID* property, but we still can try find the must info from its parent.

below is sample output from udevadm info -t /dev/ttyACM0

└─1-4:1.0
┆ P: /devices/pci0000:00/0000:00:02.1/0000:01:00.0/usb1/1-4/1-4:1.0
┆ E: DEVPATH=/devices/pci0000:00/0000:00:02.1/0000:01:00.0/usb1/1-4/1-4:1.0
┆ E: SUBSYSTEM=usb
┆ E: DEVTYPE=usb_interface
┆ E: DRIVER=cdc_acm
┆ E: PRODUCT=303a/1001/101
┆ E: TYPE=239/2/1
┆ E: INTERFACE=2/2/0
┆ E: MODALIAS=usb:v303Ap1001d0101dcEFdsc02dp01ic02isc02ip00in00
└─tty/ttyACM0
┆ P: /devices/pci0000:00/0000:00:02.1/0000:01:00.0/usb1/1-4/1-4:1.0/tty/ttyACM0
┆ M: ttyACM0
┆ R: 0
┆ U: tty
┆ D: c 166:0
┆ N: ttyACM0
┆ L: 0
┆ E: DEVPATH=/devices/pci0000:00/0000:00:02.1/0000:01:00.0/usb1/1-4/1-4:1.0/tty/ttyACM0
┆ E: SUBSYSTEM=tty
┆ E: DEVNAME=/dev/ttyACM0
┆ E: MAJOR=166
┆ E: MINOR=0

Copy link
Contributor

@RossSmyth RossSmyth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would highly recommend not bringing in regex for such an operation due to its extreme compilation weight & size cost.

Cargo.toml Outdated Show resolved Hide resolved
src/posix/enumerate.rs Outdated Show resolved Hide resolved
src/posix/enumerate.rs Show resolved Hide resolved
src/posix/enumerate.rs Outdated Show resolved Hide resolved
@RossSmyth
Copy link
Contributor

Review is tied with #201

@sirhcel
Copy link
Contributor

sirhcel commented Jul 19, 2024

Thank you for creating this PR @soiamsoNG! Looking at the MODALIAS strings is definitely something we can do for improving finding a certain device in a Docker environment.

I agree with @RossSmyth, that using the regex crate is - despite its convenience - on the heavy side. #168 contains measurements showing a significant reduction of built times for Windows by switching to regex-lite. We are currently also evaluating custom parsing of similar strings in #201 and it looks to me at a first glance that we have a good chance to get away with a much simpler parsing for MODALIAS strings than using regex or regex-lite.

Looking at file2alias.c from the Linux Kernel it looks like we might even get away without any regex magic at all. And we already got a regex-free proposal with #170 (comment).

@sirhcel
Copy link
Contributor

sirhcel commented Jul 25, 2024

Thank you @soiamsoNG and @RossSmyth for your contributions!

@sirhcel sirhcel merged commit 1e5c12b into serialport:main Jul 25, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants