2016-05-18 46 views
1

我在樹莓派3(debian)上運行node.js。如何解決運行Node.js的Raspberry Pi(Debian)上的LIBUSB_ERROR_BUSY

我有一個小型原型項目,它從我的渦輪增壓教練機上的ANT +變送器收集數據,該數據通過Suunto Movestick USB加密狗發送。

我使用Ant-Plus節點模塊來管理ANT +協議和腳本,該腳本將數據輸出到控制檯並通過REST API發送到雲存儲。

總之,切正題,這是所有工作正常,多進程啓動,並沒有問題停止,直到我無意中擊中ctrl + z代替ctrl + c

現在我只收到以下錯誤殺死的過程中,試圖運行我的腳本時:

/home/pi/ant-plus/node_modules/usb/usb.js:168 this.device .__ claimInterface(this.id) ^

Error: LIBUSB_ERROR_BUSY 
    at Error (native) 
    at Interface.claim (/home/pi/ant-plus/node_modules/usb/usb.js:168:14) 
    at GarminStick2.USBDriver.open (/home/pi/ant-plus/build/ant.js:287:20) 
    at Object.<anonymous> (/home/pi/ant-plus/sample/cadence-sensor.js:39:12) 
    at Module._compile (module.js:409:26) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Function.Module.runMain (module.js:441:10) 
    at startup (node.js:139:18) 

由於節點進程沒有被正常關閉,所以經過四處搜索後,似乎某些進程仍然連接到USB。

我已經試過各種方法來殺死進程:

ps | grep <something> 
kill <somepid> 

killall node 

不知怎的,不過,我不認爲這是節點的過程,我需要殺的,我的「感覺」像我需要以某種方式清潔USB接口,但我不知道如何做到這一點。

該項目使用node-usb庫,但我不確定是否可以用某種方式來清理它。

回答

1

我對此做了一些研究:原因是Raspberry Pi將內核驅動程序連接到連接的設備。您需要檢查內核驅動程序並在聲明該接口之前將其分離。

看到,因爲你正在使用node-usb,這裏是一些僞代碼:

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() 
}) 
+0

感謝這個,完全錯過了答覆,並沒有回過該項目一會! –

相關問題