Skip to content

usb: fix device detection when bus number is 0#295

Open
lewing wants to merge 1 commit into
sigrokproject:masterfrom
lewing:fix-usb-bus-zero
Open

usb: fix device detection when bus number is 0#295
lewing wants to merge 1 commit into
sigrokproject:masterfrom
lewing:fix-usb-bus-zero

Conversation

@lewing

@lewing lewing commented Jun 14, 2026

Copy link
Copy Markdown

Problem

On macOS (particularly Apple Silicon), libusb reports USB bus number 0 for devices. For example, a Rigol DS1052E oscilloscope connected via USB appears at bus 0, address 4.

The sr_usb_find() function in src/usb.c uses bus && addr to validate whether a bus.address specification was provided. Since bus=0 is falsy in C, this causes all devices on bus 0 to be rejected with:

Could neither determine VID:PID nor bus.address numbers.

The same issue affects the device matching filter at line 428, where bus=0 causes the filter to be skipped entirely.

This breaks USBTMC device detection for oscilloscopes and other instruments on macOS.

Fix

Change both checks to only require addr to be nonzero, since bus 0 is a valid bus number assigned by libusb on macOS.

Testing

Verified on macOS 15 (Apple Silicon M4) with a Rigol DS1052E connected via USB (VID:PID 1ab1:0588, bus 0, address 4). PulseView successfully detects and communicates with the device after this fix.

On macOS (particularly Apple Silicon), libusb reports USB bus number 0
for devices. The sr_usb_find() function used 'bus && addr' to validate
whether a bus.address specification was provided, but since bus=0 is
falsy in C, this caused all devices on bus 0 to be rejected with:
"Could neither determine VID:PID nor bus.address numbers."

The same issue affected the device matching filter, where bus=0 caused
the filter to be skipped entirely rather than matching against the
specific bus.address pair.

Fix both checks to only require addr to be nonzero, since bus 0 is a
valid bus number. This fixes USBTMC device detection (e.g. Rigol
oscilloscopes) on macOS with Apple Silicon.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant