Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying VID/PID for scanning + steamline scanning in tools #791

Merged
merged 9 commits into from
Feb 17, 2022

Conversation

pcercuei
Copy link
Contributor

A rewrite of #764.

This PR does a few things.

  • Change the separator in the backends scan string from a colon to a comma (colon still supported for backwards-compatibility)
  • Rework scanning to support having backends listed multiple times in the list
  • Add support for specifying backend params, currently only for the USB backend: e.g. usb=0456:b672
  • Update the libiio udev rule to only scan for the detected USB device
  • Unify tools on the --scan (aka -S) option and updated the documentation and man pages
  • Print usage examples on iio_readdev / iio_writedev.

The possibility to specify a USB device's VID/PID on the backends scan string makes it possible to only target a specific device, instead of probing all devices on the USB bus. This is useful for applications built around particular pieces of hardware. It also avoids disrupting the functionality of other USB devices on the bus.

Add a backup function for Windows machines.

Signed-off-by: Robin Getz <[email protected]>
so wrap it to make sure we can find it.

Signed-off-by: Robin Getz <[email protected]>
@pcercuei pcercuei requested review from rgetz and mhennerich February 17, 2022 10:17
pcercuei and others added 7 commits February 17, 2022 10:20
Instead of going through the list of enabled backends and checking for
each one whether or not we were asked to scan from it, we now go through
the user-supplied backends list, find the corresponding backend, and
call its scan function.

This change will make it possible to support scanning from the same
backend multiple times, for instance with different USB devices.

Signed-off-by: Paul Cercueil <[email protected]>
Libiio 1.x (in the dev branch) uses a comma instead of a colon as the
backends separator in the scan list string. This makes it possible to
use the colon as the VID/PID separator in the USB backend parameters.

Update the code and documentation to specify that commas should be used,
while still allowing colons as separators to be backwards-compatible.

Signed-off-by: Paul Cercueil <[email protected]>
When we do a USB scan, we open each device looking for a string "IIO",
and if it is not, then we close the device. The archirecture of libusb
is that when we are doing this, other applications are locked out from
using that device. This is known to cause some user problems on other
devices (not IIO) - most notibly HackRF and USRP.

This change adds the ability to restricting scans to certain vendors, or
specific product IDs - which is what most purpose build software is
looking for. (GNU Radio doesn't want to open every device, only the ones
it knows about).

This should allow us to play nicer with others. Examples:
 usb,local
 local,usb=0456:b673,usb=0456:b672
 usb=0456:*

VENDOR ID and PRODUCT ID are hexadecimal numbers (no prefix needed),
"*" (match any). By default (no vid:pid provided) all devices are opened
and checked (which is the previous behavour).

Signed-off-by: Robin Getz <[email protected]>
Signed-off-by: Paul Cercueil <[email protected]>
With the updated scan options, it's possible to scan usb, or ip multiple
times, and get duplicates in the list. This sorts the list, and removes
duplicates if found, so users get a minimal list.

Signed-off-by: Robin Getz <[email protected]>
Signed-off-by: Paul Cercueil <[email protected]>
Instead of scanning all USB devices everytime a new device is plugged,
which might disrupt the functionality of the unrelated devices being
scanned, only scan for the USB device we are interested in, since we
know its VID/PID.

Signed-off-by: Paul Cercueil <[email protected]>
this ensures you can do a "-S" on any utility, and it scans the same way
on all different utilities.

Signed-off-by: Robin Getz <[email protected]>
Signed-off-by: Paul Cercueil <[email protected]>
If you are given a context, but no device/channel, walk through things
and print out examples which you might be able to use, as a hint for
people. (so I can stop telling them to do it with iio_attr manually).

Signed-off-by: Robin Getz <[email protected]>
@pcercuei pcercuei force-pushed the pcercuei/usb-scan-work branch from aa35512 to 888dd29 Compare February 17, 2022 10:21
@pcercuei
Copy link
Contributor Author

@rgetz this last commit breaks iio_readdev / iio_writedev.

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.

2 participants