ni-c / heimcontrol.js

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

events.js:2817: Uncaught Error: Cannot open /dev/ #12

Closed benblustey closed 10 years ago

benblustey commented 10 years ago

I have been struggling for a week trying to figure out what went wrong. I had this running fine from outside my house and controlling an led on a breadboard. When I restarted my pi and attempted to run 'node heimcontrol.js', I am greeted with 'info - socket.io started' (expected), the two instances of 'events.js:2817: Uncaught Error: Cannot open /dev/' and no return of listening on port. I've checked and changed my permissions of /dev/ to 'drwxr-xr-x 12 pi root 3100 Sep 28 15:58 dev'. I know 777 isn't the best practice, but I was trying to see if that was the issue. I've tried to locate the events.js to dig deeper, but no luck. What should I check next? I've run out of ideas.

Thank you for putting this library together, I am really looking forward to seeing how much I can extend this through my house and backyard(chicken coop). I'm a front end dev learning node and mongo and this is an awesome project! (Apologies if this is not the correct place to post, just hoping to receive some clarity).

Edit 01: I pointed my Pi browser to 127.0.0.1:8080 and was greeted with a page 'Motion 3.2.12 Running [1] Threads' and a hyperlink 'All' which leads to settings. I am assuming that I created a video module in Heimcontrol and did not finish the setup since Motion did not detect my camera (RPi camera module).

pzdaniel commented 10 years ago

Hey benblustey,

I had the same problem! duino is looking for your arduino board by using the "terminal command" ls /dev | grep ACM If you type this in your terminal and nothing happens, you can fix the error by doing the following steps (you have to be in the heimcontrol.js directory):

  1. edit the file: board.js nano node_modules/duino/lib/board.js
  2. change the part around 75 where 'ls /dev | grep ACM' or similar is written to: 'ls /dev | grep -e usb -e USB -e ACM'
  3. save and start heimcontrol...that's it! :-)
benblustey commented 10 years ago

Hey pzdaniel!

Thank you for the response.

Entered 'ls /dev | grep ACM' and nothing was returned. Changed the line from 'ls /dev | grep ACM' (it was 75) to 'ls /dev | grep -e usb -e USB -e ACM' Saved and started (also rebooted pi) heimcontrol.js and the same error appeared :/

Have any other ideas what it might be? Would removing any instance from the db of a webcam be possible? Is that even the issue?

Thanks again for your input. I've been working on my own Node app for my chicken coop, but I saw Heimcontrol as an very scalable solution for my house!

ni-c commented 10 years ago

Hi benblustey!

What is the output if you type ls /dev | grep -e usb -e USB -e ACM in the terminal?

benblustey commented 10 years ago

Hey ni-c, thanks for your response.

I receive no response, so I am assuming that I am missing some installs?

ni-c commented 10 years ago

Seems that heimcontrol.js does not find any USB-Devices connected to your Pi, if you haven't attached an Arduino or a webcam via USB you can ignore these errors.

You can try to drop the collection of the webcam plugin from the db and restart heimcontrol.js:

mongo heimcontroljs --eval "db.Webcam.drop();"

If that doesnt work you can try to change the name of the used database in config/development.js line 6 or simply drop your old database:

mongo heimcontroljs --eval "db.dropDatabase();"

heimcontrol.js will create a new database on startup.

benblustey commented 10 years ago

Thanks ni-c,

I tried three approaches; dropped the database, clean version of heimcontroljs, and changed the name of the database, with no different outcome.

I wasn't able to use:

mongo heimcontroljs --eval "db.dropDatabase();"

returned

MongoDB shell version: 2.1.1
connecting to: heimcontroljs
[object bson_object]

So I entered the mongo bash switched to the heimcontrol db and was able to drop the db.

> show dbs
heimcontrol     (empty)

I start up heimcontrol sudo node heimcontrol.js

info  - socket.io started
heimcontrol.js listening on port 8080
events.js:2817: Uncaught Error: Cannot open /dev/
events.js:2817: Uncaught Error: Cannot open /dev/

I tried adding 'pi' as a user on the /dev/ directory, but after reboot it always changes back to

drwxr-xr-x  12 root root  3100 Oct  8 11:26 dev

Thanks again for your help on this, hopefully my early stage status isn't driving you mad.

JorisM commented 10 years ago

I ran into the same problem. After some exploring, I figured out that I had to grep for AMA instead of AMC on my raspberry pi.

benblustey commented 10 years ago

Thank you, Joris, this is what I needed and got me up and running. When entering ls /dev | grep -e usb -e USB -e ACM I am returned ttyAMA0. This time modifying line 75 of board.js w/ ls /dev | grep AMA node exits out with the below error.

info  - socket.io started
heimcontrol.js listening on port 8080
events.js:2817: Uncaught Error: Cannot open /dev/ttyAMA0
events.js:2817: Uncaught Error: Cannot open /dev/ttyAMA0

events.js:72
    throw er; // Unhandled 'error' event
        ^
Error: Serialport not open.
    at SerialPortFactory.SerialPort.write (/home/pi/heimcontrol.js/node_modules/duino/node_modules/serialport/serialport.js:246:17)
at Board.sendClearingBytes (/home/pi/heimcontrol.js/node_modules/duino/lib/board.js:112:15)
at null._onTimeout (/home/pi/heimcontrol.js/node_modules/duino/lib/board.js:37:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
npm ERR! weird error 8
npm ERR! not ok code 0

I followed the advice from an article on the raspberrypi.org forum to open serial ports.

  1. Make sure your userid (default is pi) is a member of the dialout group: sudo usermod -a -G dialout pi
  2. Stop the getty running on the GPIO serial console by remove references to /dev/ttyAMA0 from /boot/cmdline.txt
  3. Disable the getty on that serial port in /etc/inittab

After a quick reboot, I was up and running.

I tried all the above solutions on a fresh rasbian/mongo/node installs and was stuck at the same /dev directory issue. After following Joris' advice and the article, the issue was resolved.

benblustey commented 10 years ago

Got it all working now with a temp, led, and photocell! I am working on decoding some Woods RF outlets, IR leds waiting, and have my RGB led strip coming this Saturday. Can't wait to have it all together and build a slick case. Thank you @JorisM and @ni-c for the assistance, the hardware is a new realm for me.

The final modification that I needed to make to board.js was ls /dev | grep ACM to ls /dev | grep -e usb -e USB -e ACM.

mikehumphrey commented 10 years ago

I was having the same 'Uncaught Error: Cannot open /dev/' and I believe this was due to the fact that 1) I had several USB devices plugged into a USB hub and then into my BBB so the /usb/ directory contained some hidden devices, but not my Arduino because 2) As a total NUB I had not uploaded the duino.ino files to my attached Arduino. Once I uploaded the files it worked great.

tjanson commented 10 years ago

My Arduino Uno showed up as /dev/ttyAMA0 on my new Raspi B+. I’ll add this to the duino code later. Never mind, ttyAMA0 is UART or something.