usb: fix device detection when bus number is 0#295
Open
lewing wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 insrc/usb.cusesbus && addrto 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: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
addrto 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.