serialport / node-serialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!
https://serialport.io
MIT License
5.8k stars 1.01k forks source link

node serialport not displaying serialport data in raspberryPI #166

Closed nathalok closed 11 years ago

nathalok commented 11 years ago

I am trying to read the serialport data but it doesn't display anything. I have verified that the data is arriving in the serialport. The same script works fine in windows 7. Also I have tried two different approaches of reading the serial data but none of them work. The node.js version I am using is v0.9.9.

Any help will be greatly appreciated.

var sys = require('sys'); var portName = '/dev/ttyACM0' ;

///////////////////////////////////////////////// //Approach 1 ///////////////////////////////////////////////// var SerialPort = require("serialport").SerialPort var serialPort = new SerialPort(portName, { baudrate: 9600 });

serialPort.on("open", function () { console.log('open'); serialPort.on('data', function(data) { //console.log('data received: ' + data); sys.puts("here: "+data); });
serialPort.on('error', function(message) { console.log('error: ' + message); }); });

///////////////////////////////////////////////// //Approach 2 ///////////////////////////////////////////////// var serialport = require("serialport"); var SerialPort = serialport.SerialPort; // localize object constructor

var sp = new SerialPort(portName, { parser: serialport.parsers.raw });

sp.on("data", function (data) { sys.puts("here: "+data); });

beriberikix commented 11 years ago

Any progress here? I'm trying to do something similar with the serial lines not the GPIO.

nathalok commented 11 years ago

I have dropped the idea of using node-serialport. Instead I am using pySerial just to read the serial data and pass it to the node application. It works for me.

voodootikigod commented 11 years ago

are you using straight raspbian?

nathalok commented 11 years ago

yes. The image is 2013-02-09-wheezy-raspbian.

beriberikix commented 11 years ago

Yup, on a clean install via NOObs and with Johnny Five.

nathalok commented 11 years ago

Thanks will try that.

voodootikigod commented 11 years ago

What device are you connecting to.

Happy to get you to complete even if with pyserial (which is great and more established). Just want to try to get all data to recreate if I can.

On Wednesday, June 26, 2013, Jonathan Beri wrote:

Yup, on a clean install via NOObs and with Johnny Five.

— Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/166#issuecomment-20089567 .

Chris Williams @voodootikigod http://twitter.com/voodootikigod | GitHubhttp://github.com/voodootikigod

You will most likely find me working on: SaferAginghttp://www.saferaging.com/ | JSConf http://jsconf.com/ | NodeBotshttp://www.voodootikigod.com/nodebots-the-rise-of-js-robotics

nathalok commented 11 years ago

The Raspberry PI is connected to Xbee Explorer board (https://www.sparkfun.com/products/8687) which talks to Arduino wirelessly.

Here is how it looks like -

homeautomation_3

voodootikigod commented 11 years ago

Sweet nice fritzing use!

Lets try to recreate and fix thanks for the details

On Wednesday, June 26, 2013, nathalok wrote:

The Raspberry PI is connected to Xbee Explorer board ( https://www.sparkfun.com/products/8687) which talks to Arduino wirelessly.

Here is how it looks like -

[image: homeautomation_3]https://f.cloud.github.com/assets/4198123/713273/05d5ad6a-dec2-11e2-8aed-933c0c356aa9.png

— Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/166#issuecomment-20090402 .

Chris Williams @voodootikigod http://twitter.com/voodootikigod | GitHubhttp://github.com/voodootikigod

You will most likely find me working on: SaferAginghttp://www.saferaging.com/ | JSConf http://jsconf.com/ | NodeBotshttp://www.voodootikigod.com/nodebots-the-rise-of-js-robotics

voodootikigod commented 11 years ago

Can you try with the latest version of node (0.10.12) 0.9.x was a dev branch and not supported. I have tested this locally and it seems to work perfectly. I have posted how I got everything working here: https://github.com/voodootikigod/node-serialport/wiki#raspberry-pi-linux-raspbian

voodootikigod commented 11 years ago

nudge.

timoxley commented 11 years ago

bump @nathalok

nathalok commented 11 years ago

Sorry guys. Will try tonight and will post it soon. Some of the steps especially node.js installation in raspberry PI takes couple of hours. Normally I leave it to run overnight.

On Tue, Jul 30, 2013 at 10:45 AM, Tim Oxley notifications@github.comwrote:

bump

— Reply to this email directly or view it on GitHubhttps://github.com/voodootikigod/node-serialport/issues/166#issuecomment-21762592 .

beriberikix commented 11 years ago

There's official pre-built binaries: http://nodejs.org/dist/v0.10.13/node-v0.10.13-linux-arm-pi.tar.gz

Just add it to your PATH:

sudo mkdir /opt/node

/etc/profile ... NODE_JS_HOME="/opt/node" PATH="$PATH:$NODE_JS_HOME/bin" export PATH ...
nathalok commented 11 years ago

Thank everyone. Its working. 3 Cheers!