How to solve LIBUSB_ERROR_BUSY on Raspberry Pi (Debian) running Node.js

蓝咒 提交于 2019-12-06 07:31:17

I did some research into this: The reason is that the Raspberry Pi attaches a kernel driver to connected devices. You need to check for a kernel driver and detach it before claiming the interface.

Seeing as you are using node-usb, here is some pseudo code:

device.open()
const deviceInterface = device.interfaces[0]

let driverAttached = false
if (printerInterface.isKernelDriverActive()) {
   driverAttached = true
   deviceInterface.detachKernelDriver()
}

deviceInterface.claim()

// ... use the device interface

deviceInterface.release(() => {
   if (driverAttached) {
      deviceInterface.attachKernelDriver()
   }

   device.close()
})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!