GEMakers / green-bean

An Adapter for the Appliance Maker Community
GNU General Public License v2.0
57 stars 23 forks source link

Raspberry Pi setup #6

Closed gaidh closed 9 years ago

gaidh commented 9 years ago

My greenbean works fine with my macbook and GeoSpring 50, but I seem to be missing something when trying to talk to it through a Raspberry Pi Model B. The node npm installs go fine, and the device enumerates fine, but then node-hid fails to open the device:

/home/marc/development/greenbean/water-heater/node_modules/green-bean/node_modules/gea-adapter-usb/node_modules/node-hid/index.js:24 this._raw = new (Function.prototype.bind.apply(binding.HID, ^ Error: cannot open device with path 0001:0006:00 at Error (native) at new HID (/home/marc/development/greenbean/water-heater/node_modules/green-bean/node_modules/gea-adapter-usb/node_modules/node-hid/index.js:24:14) at Object.exports.bind (/home/marc/development/greenbean/water-heater/node_modules/green-bean/node_modules/gea-adapter-usb/index.js:171:22) at configuration.bind (/home/marc/development/greenbean/water-heater/node_modules/green-bean/node_modules/gea-sdk/src/main.js:26:17) ...

Here it is with lsusb: Bus 001 Device 006: ID 04d8:fcf0 Microchip Technology, Inc.

This is a pretty vanilla up-to-date raspbian image. Am I missing some kernel module or userspace package?

Thanks!

bakerface commented 9 years ago

It seems like a permissions issue. Can you try running your node.js script with sudo?

gaidh commented 9 years ago

Ah - seems obvious now. Thank you.

For future readers, a basic solution to address this (without running as root all the time) is to add a usb group: $ sudo groupadd usb

add my user to it: $ usermod -G usb whmon

and make it the default group for the usb device with /etc/udev/rules.d/50-usb.rules: SUBSYSTEM=="usb", ATTR{idVendor}="04d8", ATTR{idProduct}="fcf0", MODE="0660", GROUP="usb"

...then restart the pi. I suspect I could do a better job with the udev rule but this works ok.