somebuddy87 / node-red-contrib-usbhid

A node-hid (USB HID device access library) wrapper for nodered
Apache License 2.0
4 stars 19 forks source link

[HIDdevice:9440089.c9998f8] TypeError: Cannot read property 'on' of undefined #6

Open janvda opened 5 years ago

janvda commented 5 years ago

I don't manage to receive events from a HIDdevice using the HIDdevice node. I am getting error [HIDdevice:9440089.c9998f8] TypeError: Cannot read property 'on' of undefined Here below you see what is logged in my node-red log file (FYI: i am running node-red in docker container using balena on a raspberry pi 3B)

FYI: the getHIDdevices node seems to be working as it is returning the following:

[{"vendorId":2362,"productId":9488,"path":"0001:0004:00","release":256,"interface":0},{"vendorId":5050,"productId":1,"path":"0001:0005:00","release":256,"interface":0}]

and based on this I have set the properties of my HIDConfig node as follows VID = 2362 PID = 9488 but when deploying my flow the following issues are seen:

  1. The HIDdevice node gets status disconnected
  2. The node-red editor debug tab is reporting `TypeError: Cannot read property 'on' of undefined``
  3. The following is logged in the node-red log file:
    14.08.19 08:37:55 (+0200)  node-red  14 Aug 08:37:55 - [error] [HIDdevice:9440089.c9998f8] TypeError: Cannot read property 'on' of undefined
    14.08.19 08:37:55 (+0200)  node-red      at new usbHIDNode (/usr/src/node-red/node_modules/node-red-contrib-usbhid/usbhid/usbhid.js:38:11)
    14.08.19 08:37:55 (+0200)  node-red      at Object.createNode (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:483:31)
    14.08.19 08:37:55 (+0200)  node-red      at Flow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:176:44)
    14.08.19 08:37:55 (+0200)  node-red      at start (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:329:33)
    14.08.19 08:37:55 (+0200)  node-red      at stop.then.then (/usr/src/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:196:21)
    14.08.19 08:37:55 (+0200)  node-red      at <anonymous>
    14.08.19 08:37:55 (+0200)  node-red      at process._tickCallback (internal/process/next_tick.js:169:7)
janvda commented 5 years ago

I got this fixed by running node-red as root user.

Jamshedshoh commented 4 years ago

I got same issues

Richie765 commented 4 years ago

I had the same problem, it was because the /dev/hidraw* devices are not accessible by the user that is running Node-RED. You can run as root, but you can also change the permissions of the /dev/hidraw* entries as follows:

Add the following to: /etc/udev/rules.d/51-my-device.rules (of course modify to suit your own device)

KERNEL=="hidraw*", ATTRS{idVendor}=="1910", ATTRS{idProduct}=="1020", MODE="0666", GROUP="plugdev"

Now activate the settings (or reboot):

sudo udevadm control --reload-rules

# remove and re-insert USB device

# check permissions
ls -l /dev/hidraw*