greatscottgadgets / hackrf

low cost software radio platform
https://greatscottgadgets.com/hackrf/
GNU General Public License v2.0
6.61k stars 1.53k forks source link

Report whether other devices are sharing the USB bus #1484

Open martinling opened 1 month ago

martinling commented 1 month ago

Adds a check in hackrf_info for whether the device is on a dedicated bus.

mossmann commented 1 month ago

Is there a reason hackrf_device_list_bus_sharing() must be in libhackrf, or could it be in hackrf_info?

martinling commented 1 month ago

I started off with all the code in hackrf_info - you can see that version in this commit.

I changed it for two reasons:

  1. Because the code needs to call libusb_get_bus_number and libusb_get_parent, it becomes necessary for hackrf_info.c to include libusb.h, and also to build the binary with the necessary linker flags to link it to libusb directly rather than just transitively via libhackrf. That would have required some changes in the build system, and I suspected that it might also cause some issues for distros.

  2. I figured this might be useful information for GUI tools as well, so having a library function that did the necessary iterating and counting seemed like a nice idea.