I'm buildling a USBTMC device, which I'd like to access with WebUSB. When my device connects, the interface is immediately bound to the Linux usbtmc kernel driver, and claimInterface fails with NetworkError.
libusb provides libusb_detach_kernel_driver to explicitly hijack the device.
I can't find any information in the WebUSB specification about how implementations are supposed to handle this case. If I have requested the device, the user likely wants the webpage detaching the driver ("just make it work.") To me, it seems claimInterface should use always try to detach the kernel driver, but it would be nice with some guidance on how disruptive claimInterface ought to be.
For anyone looking for an answer, this udev rule is for a Raspberry Pi RP2040 that can then be claimed by WebUSB:
DRIVER=="usbtmc", ACTION=="add", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000a", RUN+="/bin/sh -c 'echo -n %k >%S%p/driver/unbind'"
Caveat emptor: I don't know how this works on other OSes, but I don't think it matters for the general question of how eager claimInterface should be to succeed.
I'm buildling a USBTMC device, which I'd like to access with WebUSB. When my device connects, the interface is immediately bound to the Linux
usbtmckernel driver, andclaimInterfacefails withNetworkError.libusb provides
libusb_detach_kernel_driverto explicitly hijack the device.I can't find any information in the WebUSB specification about how implementations are supposed to handle this case. If I have requested the device, the user likely wants the webpage detaching the driver ("just make it work.") To me, it seems
claimInterfaceshould use always try to detach the kernel driver, but it would be nice with some guidance on how disruptiveclaimInterfaceought to be.For anyone looking for an answer, this udev rule is for a Raspberry Pi RP2040 that can then be claimed by WebUSB:
Caveat emptor: I don't know how this works on other OSes, but I don't think it matters for the general question of how eager
claimInterfaceshould be to succeed.