node-usb / node-usb

Improved USB library for Node.js
https://node-usb.github.io/node-usb/
MIT License
1.57k stars 278 forks source link

Issues on rasperry pie with hotplug - crashing #392

Closed realwax closed 1 year ago

realwax commented 4 years ago

Used https://github.com/huhamhire/node-co2-monitor/blob/master/co2_monitor.js

it detached kernel driver https://github.com/huhamhire/node-co2-monitor/blob/master/co2_monitor.js#L58

though i see at dmesg:

925.532552] usb 1-1.2: usbfs: process 5519 (node) did not claim interface 0 before use

on hotplug events my iobroker javasscript adapter crashes:

host.ioBrokerPIB3 2020-10-29 11:59:45.379 error instance system.adapter.javascript.1 terminated with code 1 (JS_CONTROLLER_STOPPED)
host.ioBrokerPIB3 2020-10-29 11:59:45.378 error Caught by controller[0]: at Transfer.transferDone (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:454:10)
host.ioBrokerPIB3 2020-10-29 11:59:45.378 error Caught by controller[0]: at InEndpoint.EventEmitter.emit (domain.js:483:12)
host.ioBrokerPIB3 2020-10-29 11:59:45.377 error Caught by controller[0]: at InEndpoint.emit (events.js:314:20)
host.ioBrokerPIB3 2020-10-29 11:59:45.377 error Caught by controller[0]: at Object.onceWrapper (events.js:420:28)
host.ioBrokerPIB3 2020-10-29 11:59:45.376 error Caught by controller[0]: at InEndpoint. (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-co2-monitor/co2_monitor.js:90:33)
host.ioBrokerPIB3 2020-10-29 11:59:45.375 error Caught by controller[0]: at Interface.attachKernelDriver (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:330:21)
host.ioBrokerPIB3 2020-10-29 11:59:45.374 error Caught by controller[0]: Error: LIBUSB_ERROR_BUSY
javascript.1 2020-10-29 11:59:44.770 error (1086) Error: LIBUSB_ERROR_BUSY at Interface.attachKernelDriver (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:330:21) at InEndpoint. (/opt/iobroker/node_mo
javascript.1 2020-10-29 11:59:44.769 error (1086) Error: LIBUSB_ERROR_BUSY
javascript.1 2020-10-29 11:59:44.768 error (1086) An error happened which is most likely from one of your scripts, but the originating script could not be detected.
javascript.1 2020-10-29 11:59:44.742 error (1086) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_STALL

When I unbind the adapter myself echo '1-1.2:1.0' >/sys/bus/usb/drivers/usbfs/unbind

The adapter crashes again:

host.ioBrokerPIB3 2020-10-29 12:03:16.242 error instance system.adapter.javascript.1 terminated with code 1 (JS_CONTROLLER_STOPPED)
host.ioBrokerPIB3 2020-10-29 12:03:16.242 error Caught by controller[1]: at Device. (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:316:7)
host.ioBrokerPIB3 2020-10-29 12:03:16.241 error Caught by controller[1]: at Interface. (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-co2-monitor/co2_monitor.js:94:26)
host.ioBrokerPIB3 2020-10-29 12:03:16.240 error Caught by controller[1]: at CO2Monitor.EventEmitter.emit (domain.js:483:12)
host.ioBrokerPIB3 2020-10-29 12:03:16.240 error Caught by controller[1]: at CO2Monitor.emit (events.js:314:20)
host.ioBrokerPIB3 2020-10-29 12:03:16.239 error Caught by controller[1]: at CO2Monitor. (script.js.climate.CO2_Monitor_Wohnzimmer:74:13)
host.ioBrokerPIB3 2020-10-29 12:03:16.239 error Caught by controller[1]: at CO2Monitor.disconnect (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-co2-monitor/co2_monitor.js:88:24)
host.ioBrokerPIB3 2020-10-29 12:03:16.238 error Caught by controller[1]: at InEndpoint.Endpoint.stopPoll (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:398:9)
host.ioBrokerPIB3 2020-10-29 12:03:16.238 error Caught by controller[1]: Error: Polling is not active.
host.ioBrokerPIB3 2020-10-29 12:03:16.237 error Caught by controller[0]: at Transfer.transferDone (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:454:10)
host.ioBrokerPIB3 2020-10-29 12:03:16.236 error Caught by controller[0]: at InEndpoint.EventEmitter.emit (domain.js:483:12)
host.ioBrokerPIB3 2020-10-29 12:03:16.236 error Caught by controller[0]: at InEndpoint.emit (events.js:326:22)
host.ioBrokerPIB3 2020-10-29 12:03:16.235 error Caught by controller[0]: at Object.onceWrapper (events.js:420:28)
host.ioBrokerPIB3 2020-10-29 12:03:16.235 error Caught by controller[0]: at InEndpoint. (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-co2-monitor/co2_monitor.js:90:33)
host.ioBrokerPIB3 2020-10-29 12:03:16.234 error Caught by controller[0]: at Interface.attachKernelDriver (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:330:21)
host.ioBrokerPIB3 2020-10-29 12:03:16.232 error Caught by controller[0]: Error: LIBUSB_ERROR_BUSY
javascript.1 2020-10-29 12:03:15.650 error (4453) at Device. (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:316:7)
javascript.1 2020-10-29 12:03:15.649 error (4453) at Interface. (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-co2-monitor/co2_monitor.js:94:26)
javascript.1 2020-10-29 12:03:15.649 error (4453) at CO2Monitor.EventEmitter.emit (domain.js:483:12)
javascript.1 2020-10-29 12:03:15.648 error (4453) at CO2Monitor.emit (events.js:314:20)
javascript.1 2020-10-29 12:03:15.648 error (4453) at CO2Monitor. (script.js.climate.CO2_Monitor_Wohnzimmer:73:13)
javascript.1 2020-10-29 12:03:15.647 error (4453) at CO2Monitor.disconnect (/opt/iobroker/node_modules/iobroker.javascript/node_modules/node-co2-monitor/co2_monitor.js:88:24)
javascript.1 2020-10-29 12:03:15.646 error (4453) at InEndpoint.Endpoint.stopPoll (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:398:9)
javascript.1 2020-10-29 12:03:15.645 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: Polling is not active.
javascript.1 2020-10-29 12:03:15.641 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_ERROR_OTHER
javascript.1 2020-10-29 12:03:15.620 error (4453) Error: LIBUSB_ERROR_BUSY at Interface.attachKernelDriver (/opt/iobroker/node_modules/iobroker.javascript/node_modules/usb/usb.js:330:21) at InEndpoint. (/opt/iobroker/node_mo
javascript.1 2020-10-29 12:03:15.620 error (4453) Error: LIBUSB_ERROR_BUSY
javascript.1 2020-10-29 12:03:15.619 error (4453) An error happened which is most likely from one of your scripts, but the originating script could not be detected.
javascript.1 2020-10-29 12:03:15.560 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.559 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.559 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.558 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.557 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.556 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.554 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE
javascript.1 2020-10-29 12:03:15.550 error (4453) script.js.climate.CO2_Monitor_Wohnzimmer: Error: LIBUSB_TRANSFER_NO_DEVICE

It seems like @humanhire did use and include everything right and he can't reproduce my issue. It seems like it's related to lib_usb and raspberry pie and kernel.

Can someone help me further? My udev rules are in place and I can read from the device. This is related to https://github.com/tessel/node-usb/issues/390

Thank you

Raspberry 3b+ Debian Buster Linux 5.4.72-v7+ #1356 SMP Thu Oct 22 13:56:54 BST 2020 armv7l GNU/Linux Node.js v12.19.0 NPM 6.14.8

thegecko commented 1 year ago

Closing this issue due to inactivity, please create a new issue as required.