Monday, August 09, 2021

Re: libusb1 and Yoctopuce USB sensors

On 2021-08-08, Julian Smith <jules@op59.net> wrote:
> I've been trying to get a yoctopuce (https://www.yoctopuce.com/) USB
> sensor to work on OpenBSD, but have run into problems.
>
> The sensor has Linux code
> (https://github.com/yoctopuce/yoctolib_cpp.git) that uses libusb, but
> on OpenBSD using the libusb1 package, libusb_kernel_driver_active() and
> libusb_detach_kernel_driver() are returning error code -12
> (LIBUSB_ERROR_NOT_SUPPORTED).
>
> I found some rather old advice saying that these errors can be
> ignored (https://github.com/apple/cups/issues/4088), but then i get an
> error -12 from libusb_submit_transfer().

There's no support for detaching a kernel USB driver from userland.

If the device is attaching to a driver other than ugen, your first is to
prevent that and try again. Devices often attach to uhid(4) and libusb
functionality is very limited there. But that's an easy case to work around,
there's a UQ_BAD_HID quirk (see /usr/src/sys/dev/usb/usb_quirks.c),
you can add an entry using that to prevent the vid/pid of your device
from attaching and build a new kernel, it is then likely to end up on
ugen(4) and then has a better chance to do what you need.

> I notice that 'pkg_info -R libusb1' shows just 9 ports depend on
> libusb1, so i'm wondering whether the libusb1 port is expected to work
> generally on OpenBSD, or whether it be better to try to use the usb(4)
> ioctl API?

Many more use it via libusb-compat. Support is limited though and there's
some resistance to doing anything to help userland control of USB devices
so if it still doesn't work I'd suggest controlling it from another OS
unless you fancy writing a kernel driver.

--
Please keep replies on the mailing list.

No comments:

Post a Comment