ni-c / heimcontrol.js

Home-Automation with node.js and Raspberry PI
MIT License
1.41k stars 297 forks source link

Error:events.js #47

Closed djumaka closed 10 years ago

djumaka commented 10 years ago

I try to install heimcontrol. All is fine as well as mongo. USB arduino connected and "duino" sketch uploaded. But I get:

=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================
   info  - socket.io started
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
heimcontrol.js listening on port 18080

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Error Invalid argument calling write(...)

I've done the trick of not finding the arduino and as Arduino is connected I get:

$ls /dev | grep -e usb -e USB -e ACM
ttyUSB0
usbmon0
usbmon1
usbmon2

TIA.

pwillard commented 10 years ago

I get this too...

ni-c commented 10 years ago

Hi,

this might be a problem with the duino-module. Which platform and OS are you using?

You can try to edit the file ./node_modules/duino/lib/board.js in line 75 and change

child.exec('ls /dev | grep ACM', function(err, stdout, stderr){

into

child.exec('ls /dev | grep -e usb -e USB -e ACM', function(err, stdout, stderr){

You can also try to enable the debug messages of duino in ./plugins/arduino/index.js line 22:

this.board = new duino.Board({debug: true});
pwillard commented 10 years ago

OK, after that... it does get a bit more verbose...

info - socket.io started connect.multipart() will be removed in connect 3.0 visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives connect.limit() will be removed in connect 3.0 heimcontrol.js listening on port 8080

/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:378 throw err; ^ Error: Evaluating /home/pi/heimcontrol.js/plugins/arduino/index.js as module "/home/pi/heimcontrol.js/plugins/arduino/index.js" failed with error: SyntaxError: Unexpected token : at Function.req.load (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:2483:23) at Object.context.load (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1865:21) at Object.Module.load (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1064:29) at Object.Module.fetch (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1054:66) at Object.Module.check (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1084:26) at Object.Module.enable (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1381:22) at Object.context.enable (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1737:39) at Object. (/home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:1366:33) at /home/pi/heimcontrol.js/node_modules/requirejs/bin/r.js:369:23

pwillard commented 10 years ago

well, actually... it started working after a reboot.

djumaka commented 10 years ago

Hi, doesn't work for me.

as I added the debug in the plugins/arduino/index.js (the 1st thing I already had). This is what I got:

info - socket.io started connect.multipart() will be removed in connect 3.0 visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives connect.limit() will be removed in connect 3.0 heimcontrol.js listening on port 18080 1390854043531 duino info attempting to find Arduino board 1390854043542 duino info found board at undefined 1390854043543 duino info binding serial events

events.js:72 throw er; // Unhandled 'error' event ^ Error: Error Invalid argument calling write(...)

I run it with "sudo node heimcontrol.js" as normal run resulted in smth like "can not read /dev/usbmon2" or similar. I am with elementaryos (ubuntu).

ni-c commented 10 years ago
1390854043542 duino info found board at undefined

Looks like duino can't find your arduino board because there are 4 USB devices, ttyUSB0, usbmon0, usbmon1 and usbmon2:

$ls /dev | grep -e usb -e USB -e ACM
ttyUSB0
usbmon0
usbmon1
usbmon2

As a dirty workaround you can try to change line 85 in ./node_modules/duino/lib/board.js from:

possible = usb.pop();

into

possible = 'ttyUSB0';
djumaka commented 10 years ago

Changin "ls /dev | grep ACM" into "ls /dev | grep USB" did the trick. Why are you looking for ACM? Just asking.

ni-c commented 10 years ago

On the Raspberry PI with Raspbian the arduino has the device name 'ttyACM0':

$ ls /dev | grep -e usb -e USB -e ACM
ttyACM0

https://www.rfc1149.net/blog/2013/03/05/what-is-the-difference-between-devttyusbx-and-devttyacmx/

pwillard commented 10 years ago

Just wanted to confirm... the USB fixed it,