Node.js 0.8.1


26 posts   Page 1 of 2   1, 2
by doowttam » Sun Jul 01, 2012 5:33 pm
I think I have Node.js 0.8.1 up and running.

I followed the tutorial found here: http://elsmorian.com/post/23474168753/n ... spberry-pi for version 0.6.15. I had to make a few additions, though, to get the latest version.

First, I had to set a flag for support of armv7 features. (I'm out of my comfort zone here, but found some information in this thread about V8: https://groups.google.com/group/v8-user ... a2eea6002d)

Code: Select all
export GYP_DEFINES="armv7=0"

I also had to comment out line 171 - 176 in deps/v8/SConstruct, similar to the lines already mentioned in the tutorial.

Finally, I had to change my CPU/GPU ram split from the default to give the CPU more memory. Otherwise I ran into out of memory errors when compiling.

It seems to be running fine, but I ran into an issue when installing modules. It looks like something might be bad with SSL. I'm running into this error:

Code: Select all
npm ERR! Error: 1074417664:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR!
npm ERR!     at CleartextStream._puller (tls.js:519:24)
npm ERR!     at CleartextStream.CryptoStream._pull (tls.js:453:19)
npm ERR!     at SecurePair.cycle (tls.js:744:20)
npm ERR!     at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.EventEmitter.emit (events.js:88:17)
npm ERR!     at TCP.onread (net.js:397:14)

So, now I'm off to try to figure that out.
Posts: 2
Joined: Sat Jun 30, 2012 5:51 am
by plwebse » Sun Jul 01, 2012 9:29 pm
This http://stackoverflow.com/questions/8874 ... ithout-ssl works on my cubox witch uses an arm7 to.
Posts: 1
Joined: Sun Jul 01, 2012 9:23 pm
by RadioactiveMouse » Wed Jul 04, 2012 11:58 am
If you're on Arch Linux you can just run

Code: Select all
pacman -S nodejs


and it should do it all for you. ;)
Posts: 21
Joined: Wed Nov 16, 2011 10:48 am
by Bendis » Mon Jul 09, 2012 9:11 pm
I'm on Arch Linux, using the official RPi image, and I have the same problem. Node.js 0.8.1 is istalled via pacman. Some binary incompatibility between nodejs and openssl?

Code: Select all
[bendis@bendis-rpi ~]$ npm install underscore
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/underscore
npm ERR! Error: 1074597888:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR!
npm ERR!     at CleartextStream._puller (tls.js:519:24)
npm ERR!     at CleartextStream.CryptoStream._pull (tls.js:453:19)
npm ERR!     at SecurePair.cycle (tls.js:744:20)
npm ERR!     at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.EventEmitter.emit (events.js:88:17)
npm ERR!     at TCP.onread (net.js:397:14)
npm ERR!  [Error: 1074597888:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR! ]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.1.9-28-ARCH+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "underscore"
npm ERR! cwd /home/bendis
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.33
npm ERR! message 1074597888:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR! message
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/bendis/npm-debug.log
npm ERR! not ok code 0
Posts: 2
Joined: Mon Jul 09, 2012 9:06 pm
by RadioactiveMouse » Tue Jul 10, 2012 8:06 am
Bendis wrote:I'm on Arch Linux, using the official RPi image, and I have the same problem. Node.js 0.8.1 is istalled via pacman. Some binary incompatibility between nodejs and openssl?

Code: Select all
[bendis@bendis-rpi ~]$ npm install underscore
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/underscore
npm ERR! Error: 1074597888:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR!
npm ERR!     at CleartextStream._puller (tls.js:519:24)
npm ERR!     at CleartextStream.CryptoStream._pull (tls.js:453:19)
npm ERR!     at SecurePair.cycle (tls.js:744:20)
npm ERR!     at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.EventEmitter.emit (events.js:88:17)
npm ERR!     at TCP.onread (net.js:397:14)
npm ERR!  [Error: 1074597888:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR! ]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.1.9-28-ARCH+
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "underscore"
npm ERR! cwd /home/bendis
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.33
npm ERR! message 1074597888:error:1408D108:SSL routines:SSL3_GET_KEY_EXCHANGE:wrong signature length:../deps/openssl/openssl/ssl/s3_clnt.c:1617:
npm ERR! message
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/bendis/npm-debug.log
npm ERR! not ok code 0


Have you installed openssl? As I remember it's an optional dependency which means it needs to be installed seperately I think. ;)
Posts: 21
Joined: Wed Nov 16, 2011 10:48 am
by Bendis » Tue Jul 10, 2012 8:15 am
Hi, openssl is installed, version 1.0.1.c-1. It is indeed an optional dependency, but it was already installed in the arch linux image.

I've just created an arch linux bug report: https://bugs.archlinux.org/task/30620
Posts: 2
Joined: Mon Jul 09, 2012 9:06 pm
by gflarity » Wed Jul 11, 2012 1:10 am
With some help from Ben Noordhuis I was able to solve the SSL issue. You need to configure with --shared-openssl.

For a binary and complete working compile instructions checkout https://github.com/gflarity/node_pi.

Cheers,
Geoff
Posts: 4
Joined: Wed Jul 11, 2012 1:06 am
by XavM » Thu Jul 12, 2012 7:37 am
@gflarity : Really good news you were able to solve the SSL issue and even better you give away some nice binaries to dowload, saving us hours of native compiling (more than 2 hours on my Pi)

By the way : did some one achieved a "cross compile" build with node.js (and how) ?
Posts: 35
Joined: Thu May 31, 2012 11:29 pm
by njoyard » Fri Jul 13, 2012 12:11 pm
@gflarity, thanks a lot I was stuck on the make install step for ages...
Posts: 2
Joined: Thu Jun 28, 2012 8:47 am
by botdream » Tue Jul 17, 2012 3:30 pm
Thanks guys for your work, I was able to assemble some simple instructions here:

- Node.js v0.8.2: https://github.com/nneves/R2C2_WebInter ... eV0.8.x.md

- Node.js v0.6.20: https://github.com/nneves/R2C2_WebInter ... V0.6.20.md

Thanks to @gflarity for making the patch available (errr, to many lazy ppl doing manual edit :P )

Regards,
Nelson.
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by swestcott » Fri Aug 17, 2012 7:40 am
I've tried to compile node's v8.0 branch with @gflarity's patch, but I consistently get an out of memory error after about 40mins. Am I doing something obviously wrong?

Code: Select all
  g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DENABLE_DEBUGGER_SUPPORT' '-DV8_TARGET_ARCH_ARM' '-DUSE_EABI_HARDFLOAT=0' -I../deps/v8/src  -Wall -pthread -fno-strict-aliasing -O2 -fno-strict-aliasing -fno-tree-vrp -fomit-frame-pointer -fno-rtti -fno-exceptions -MMD -MF /home/simon/code/node/out/Release/.deps//home/simon/code/node/out/Release/obj.target/v8_base/deps/v8/src/hydrogen.o.d.raw -march=armv6 -c -o /home/simon/code/node/out/Release/obj.target/v8_base/deps/v8/src/hydrogen.o ../deps/v8/src/hydrogen.cc
In file included from ../deps/v8/src/v8utils.h:32:0,
                 from ../deps/v8/src/v8.h:56,
                 from ../deps/v8/src/hydrogen.cc:28:
../deps/v8/src/platform.h:170:15: note: the mangling of ‘va_list’ has changed in GCC 4.4
virtual memory exhausted: Cannot allocate memory
make[1]: *** [/home/simon/code/node/out/Release/obj.target/v8_base/deps/v8/src/hydrogen.o] Error 1
make[1]: Leaving directory `/home/simon/code/node/out'
make: *** [node] Error 2
Posts: 1
Joined: Tue Aug 14, 2012 10:12 pm
by Heater » Fri Aug 17, 2012 1:36 pm
Did you adjust your CPU/GPU ram split from the default to give the CPU more memory as suggested above?
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by Heater » Fri Aug 17, 2012 2:24 pm
gflarity,

In your compile instructions at https://github.com/gflarity/node_pi the line
Code: Select all
git checkout origin/v0.8.2-release -b v0.8.2-release

failed. Seems to not know that version and something about conflicting git commands.
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by botdream » Tue Sep 04, 2012 11:38 am
Heater wrote:gflarity,

In your compile instructions at https://github.com/gflarity/node_pi the line
Code: Select all
git checkout origin/v0.8.2-release -b v0.8.2-release

failed. Seems to not know that version and something about conflicting git commands.


FYI: moved my instructions to a separated repo: https://github.com/nneves/Raspberrypi_NodeJS

@Heater, was also getting that error, I've changed it to (clone a branch locally from v0.8.2):
git clone -b v0.8.2 git://github.com/joyent/node.git
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by Heater » Thu Sep 06, 2012 11:03 am
botdream,

Thanks for the update. Those instructions worked like a charm.

Should we be worried about all those errors in make test? That last one, where it stops, looks like a python exception in the test harness rather than a JS error but there are some of those as it runs.

I had a little issue with serialport:

$ sudo npm -g install serialport

failed with "Error: EACCES, stat '/root/.node-gyp/0.8.2'"

Running that as root succeeded though.

Seems to pull in an awful lot of new node packages for a serial port.

What is "node-gyp" anyway?
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by botdream » Thu Sep 06, 2012 3:57 pm
Thanks, glad to help (even taking so much time to answer)!

Code: Select all
Should we be worried about all those errors in make test? That last one, where it stops, looks like a python exception in the test harness rather than a JS error but there are some of those as it runs.


errr, to be honest I never used them before... I did try some fixing, but took me precious time and had to go on with other stuff!

Code: Select all
I had a little issue with serialport:

$ sudo npm -g install serialport

failed with "Error: EACCES, stat '/root/.node-gyp/0.8.2'"

Running that as root succeeded though.


I also add that problem and also install it with sudo. At the moment I stopped installing serialport has a node global package (-g) and install it with my current user in the current project:

$ npm install serialport

this will add node_modules directory to your current project, and I also install other packages this way! Why I'm doing this, you ask? ... well, I've discovered that you may define a local file package.json where you may list your project dependencies and to install that in a local node_modules folder you just need to run:

$ npm install

https://github.com/nneves/Raspberrypi_G ... ckage.json

I found this method to be simpler for others to follow instructions.

What is "node-gyp" anyway?

Previously node compiled stuff (packages that require to be built/compiled locally) with node-waf and then they upgrade to node-gyp. I'm not sure what are the real differences, but node-gyp is now the standard tool (it seems to be based in python, so it explains your error tracking) ... I'll have to speak with some node.js gurus to find out about this (and I will attend to a Javascript conference soon ;) ).

There seems to be some problems ahead on the newer version (compiling on an Debian ARM HF platform), so I've just tested this with node v0.8.2 and need to test this on newer version... I think problems appear after v0.8.4, node compiles and runs but NPM get some illegal instructions ... but need to do more testing, my test environment just died on me, so maybe illegal instructions came from a faulty SD card.

For now I'm pretty happy with node v0.8.2 on the rPI.

Regards,
Nelson.
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by Heater » Thu Sep 06, 2012 4:12 pm
Thanks again for the info botdream, I had not realized that waf was out and gyp was in.

I'm going to very happy to get serial data from my attached Propeller chip served up to a browser via web sockets (socket.io). node.js makes this so easy.
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by botdream » Thu Sep 06, 2012 4:35 pm
I'm glad to see someone else going this way, node.js + microcontroller, the best of the 2 worlds ;)

I'm currently doing some test with GPIO remote control with node.js WebInterface, my front-end and instructions are still a work-in-progress, currently focused on the core. Already have flatiron on node.js serving static resources (html, css, js, etc), and mapping a REST uri to control the GPIOs. Recently added WebSockets support and going to give support via XMPP soon (Gtalkbot to also control GPIOs):
https://github.com/nneves/Raspberrypi_GPIO

Yeah, socket.io rockz ;)

On this other project (experimental branch v1.0.0) I'm using serialport to communicate with the board microcontroller: https://github.com/nneves/R2C2_WebInterface/tree/v1.0.0

At the moment I'm getting a super-speed 35 ms response time on the REST requests, WebSockets are much quicker, but haven't found a way to measure it yet ;)

Good luck with your project ;)
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by Heater » Fri Sep 07, 2012 12:58 am
botdream,

You have a broken link on your Raspiberrypi_GPIO page, should be:
https://github.com/JamesBarwell/rpi-gpio.js
Thing is the link looks right but does not work when I click on it for some reason.

On the rpi-gpio page it says:
All of the functions relating to the pins within this module are asynchronous, so where necessary - for example in reading the value of a pin - a callback must be provided.


Why does he do that? The idea of asynchronous I/O is that you don't hang around waiting whilst some potentially long winded I/O is happening. BUT reading and writing a GPIO is about as fast as reading a property out of an object and requires no waiting. Having to use call backs for that seems to have no benefit, makes the code more complex and slower.

Or am I wrong, rpi-gpio reads/writes /sys/class/gpio, is it so that those accesses can block for a while?

Asyncbchronous is required for waiting on a pin change of course.
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by botdream » Sat Sep 08, 2012 10:23 pm
Hi Heater,

botdream,
You have a broken link on your Raspiberrypi_GPIO page, should be:
https://github.com/JamesBarwell/rpi-gpio.js
Thing is the link looks right but does not work when I click on it for some reason.


Thanks, forgot to double check! Fixed it! But I really need to make a proper README for this project, still have loads of things to do! I'm also waiting for some front-end upgrade from a friend, so WIP label still on ;)

On the rpi-gpio page it says:
All of the functions relating to the pins within this module are asynchronous, so where necessary - for example in reading the value of a pin - a callback must be provided.


Why does he do that? The idea of asynchronous I/O is that you don't hang around waiting whilst some potentially long winded I/O is happening. BUT reading and writing a GPIO is about as fast as reading a property out of an object and requires no waiting. Having to use call backs for that seems to have no benefit, makes the code more complex and slower.

Or am I wrong, rpi-gpio reads/writes /sys/class/gpio, is it so that those accesses can block for a while?

Asyncbchronous is required for waiting on a pin change of course.


I believe that it may block, but I don't know for sure ... maybe someone else could back this up with a more technical info. So, if it blocks, even if for a short time of a few ms, it may take longer in some un-expected situation and if this may happen it's better to have and asynchronous way of doing it in a node module.

On my code, I'll try to find a cleaner way for all that callbacks, I started to do some tests but I'm still learning my ways into node.js and javascript, so things still take some time to get there in a more clear way.
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by Heater » Sun Sep 09, 2012 1:46 pm
I think we should assume any file I/O can block. And so that gpio module is right to use callbacks.

But you can access the GPIO registers directly, given enough permisions, in which case no blocking would happen and you would not need call backs.

That would require a little bit of C code to do the job. I think I feel a new little project comming on. A synchronous GPIO module for node.js.
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by botdream » Sun Sep 09, 2012 3:29 pm
I agree!

That would require a little bit of C code to do the job. I think I feel a new little project comming on. A synchronous GPIO module for node.js.


You know what would be awesome, a C app doing proxy/gateway to the GPIOs, this app would manage all GPIO related stuff, export/un-export/read_sync/write_sync/read_async/write_async/etc (in future could map GPIO interrupts - think it's not available at kernel level yet), and this proxy app would have an API via TCP/IP (or maybe even using higher level http for REST API). Maybe there is such thing already, but haven't look for it yet! There are some examples for C and Python to access gpios ;) ... I'm a bit busy at the moment cause I'll be presenting my node.js demos at a Javascript event in the end of September, maybe after I can have a look at this ... or maybe you will get there first ;)

Having such app, node.js would use tcp/ip messages to request/set data with the possibility of sync or async methods. I'm also reading some nice node.js book and I've just read that node.js also implements Unix sockets for in-process communication (using OS file instead of a tcp/ip socket): Hands-on Node (from Pedro Teixeira) - Unix sockets - page 78.

ps: I've just updated my RaspberryPi_GPIO node.js project, refactored my code, its a bit cleaner now.
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by Heater » Mon Sep 10, 2012 9:10 am
I'm not following you. We can create such an app, GPIO to net, alreay in Node.js. In fact that is pretty much what I want to do, GPIO to web socket server (node.js) to browser, as a first experiment. Use google-chrome in app mode and you a have what looks like a dedicated application for managing your microcontroller, use a local html and js files and you don't need a web server in between.

Anyway what I was getting at is making a node.js module that includes some C code to do the GPIO access directly to the registers, then you can do synchronous GPIO. I already had some luck with tweaking GPIO from C but no idea how to use C code in a node.js module.
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm
by botdream » Mon Sep 10, 2012 10:00 am
I'm not following you. We can create such an app, GPIO to net, alreay in Node.js. In fact that is pretty much what I want to do, GPIO to web socket server (node.js) to browser, as a first experiment. Use google-chrome in app mode and you a have what looks like a dedicated application for managing your microcontroller, use a local html and js files and you don't need a web server in between.


Ok, that makes more sense! I had the idea that you wanted to completely isolate the GPIO functionality in a C app.

Anyway what I was getting at is making a node.js module that includes some C code to do the GPIO access directly to the registers, then you can do synchronous GPIO. I already had some luck with tweaking GPIO from C but no idea how to use C code in a node.js module.


I'm after the same thing, also looking into on how to make some C code on a node package... my tip, maybe we could look at one of the node packages on github that uses C code.
Posts: 19
Joined: Mon Sep 12, 2011 1:09 pm
by Heater » Mon Sep 10, 2012 4:23 pm
One way to use C/C++ from node.js is to use the foreign function interface (ffi). That allows you to call functions in C existing libraries. Looks very simple to use but it did not work for me yet. It is potentially quite slow.

https://github.com/rbranson/node-ffi

Another way to do it is to build your self a v8 interpreter with the extra functions you want add in. This I did get working on my PC at least and should be faster running.

http://syskall.com/how-to-write-your-own-native-nodejs-extension
Posts: 1252
Joined: Tue Jul 17, 2012 3:02 pm