Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

feat: [linux] expose devnum and busnum #149

Merged

Conversation

efuturetoday
Copy link
Contributor

@efuturetoday efuturetoday commented Jul 23, 2021

Hello,

this commit exposes the devnum and busnum to the library.
I use this to get the path for the device on ubuntu for udev.

Before this change the device.deviceAddress and device.locationId were set to zero.


Related to #8 and #51

item->deviceAddress = 0;
item->locationId = 0;
item->deviceAddress = strtol(udev_device_get_sysattr_value(dev,"devnum"), NULL, 10);
item->locationId = strtol(udev_device_get_sysattr_value(dev,"busnum"), NULL, 10);
Copy link
Owner

Choose a reason for hiding this comment

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

Reference to others doing something similar, https://github.com/OpenXT/vusb-daemon/blob/ed721b3caa4b0fc93a54fac6b86cad17228ce842/src/udev.c#L383-L387

It's using 10 because the devnum and busnum are base 10 vs the others are base 16

What:		/sys/bus/usb/devices/usbX/busnum
Description:
		Number of the bus.

[...]

What:		/sys/bus/usb/devices/usbX/devnum
Description:
		USB interface device number, in decimal.

[...]

What:		/sys/bus/usb/devices/usbX/idProduct
Description:
		Product ID, in hexadecimal.

What:		/sys/bus/usb/devices/usbX/idVendor
Description:
		Vendor ID, in hexadecimal.

-- https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-usb

@MadLittleMods MadLittleMods merged commit 2f82eb2 into MadLittleMods:master Jan 20, 2022
@MadLittleMods
Copy link
Owner

Thanks for the contribution @efuturetoday 🙂 Sorry for the delay 🙇

MadLittleMods added a commit that referenced this pull request Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants