Skip to content

Use bus_id() instead of busnum() when constructing/matching on DeviceArg#60

Open
dingari wants to merge 3 commits into
collabora:mainfrom
genkiinstruments:device-arg-bus-id
Open

Use bus_id() instead of busnum() when constructing/matching on DeviceArg#60
dingari wants to merge 3 commits into
collabora:mainfrom
genkiinstruments:device-arg-bus-id

Conversation

@dingari

@dingari dingari commented May 26, 2026

Copy link
Copy Markdown
Contributor

busnum() is only available on Linux. The cross-platform equivalent is bus_id().

  • Linux: String version of the busnum (e.g. "001")
  • MacOS: Top byte of the location ID (e.g. "01")
  • Windows: Unsure

In any case, it should be consistent with the output of the list command in the example.

…ching on DeviceArg

busnum() is only available on Linux. The cross-platform equivalent is
bus_id().

* Linux: String version of the busnum (e.g. \"001\")
* MacOS: Top byte of the location ID (e.g. \"01\")
* Windows: Unsure

In any case, it should be consistent with the output of the `list`
command  in the example

@sjoerdsimons sjoerdsimons left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Changes seems fine; If you could fix the libusb example so CI succeeds then this should be ready to merge

@dingari dingari force-pushed the device-arg-bus-id branch from f053ba1 to 3db3a72 Compare June 16, 2026 22:21
.iter()
.find(|d| match d {
Ok(device) => {
device.bus_number() == dev.bus_number && device.address() == dev.address

@dingari dingari Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't know which is better...

let bus_number = dev.bus_id.parse().unwrap();
device.bus_number() == bus_number && device.address() == dev.address

or

let bus_id = format!("{:03}", device.bus_number());
bus_id == dev.bus_id && device.address() == dev.address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants