Intel® NUCs
Assistance in Intel® NUC products
Announcements
All support for Intel® NUC 7 - 13 systems is transitioning to ASUS. Read more.
13511 Discussions

Problem with Johnny-five and node-pixel library on galileo node.js server

KStrz
Novice
1,714 Views

Hi Guys!

Let me sketch my project before I'll describe my problem. I want to build a node.js server on my galileo gen 2. Server will be responsible for downloading color sequences from the internet (using wifi), analysing this sequences using johnny-five and node-pixel libraries, sending this to arduino due using usb host and finally displaying desired colors on LED diodes strip (WS2812B). Code looks as follows:

var express = require('express'),

app = express(),

server = require('http').createServer(app),

io = require('socket.io').listen(server),

SerialPort = require('serialport').SerialPort;

var pixel = require("node-pixel");

var five = require("johnny-five");

var strip;

server.listen(3000);

var board = new five.Board({

port: new SerialPort("/dev/ttyACM0", {

baudrate: 240000,

buffersize: 1,

})

});

board.on("ready", function() {

console.log("Board on");

strip = new pixel.Strip({

data: 6,

length: 150,

board: this,

controller: "FIRMATA",

});

strip.on("ready", function() {

//test to check if everything works

console.log("Strip ready, let's go");

//display green color on 5th pixel.

strip.pixel(4).color("rgb( 000 , 255 , 000)");

strip.show();

});

});

app.get('/', function(req, res){

console.log("Connected");

});

io.sockets.on('connection', function(socket){

socket.on('send pixels', function(data){

//socket which sends led colors to arduino due

});

});

When I run this code on galileo I get on output:

root@galileo:/node_app_slot# node main.js

1444644264675 SerialPort /dev/ttyACM0 1444644264761 Connected /dev/ttyACM0

Illegal instruction

I don't know what to do with that. Maybe some of you faced the same problem? I'll add that when I'll run this code on computer it works fine.

Node version: v0.10.38

6 Replies
Sergio_A_Intel
Employee
430 Views

Hi

What image are you using? I tried to run the code and got an error on the first try, because the libraries you are using are missing. From where did you download the Johnny-five and the node-pixel libraries and how did you install them?

Were those 3 lines the full error you received? I noticed in your code you use a baudrate of 240000. Can you try with 152000?

Sergio

KStrz
Novice
430 Views

1. Image version: 3.8.7-yocto-standard GNU/Linux

2. Libraries are missing because you have to download them I download node.js modules using npm. So u need to use command (in node_app_slot folder): npm install express socket.io serialport johnny-five node-pixel

3. Those three lines are related with lines 12-18.

4. I'll try to decrease this baudrate

 

Konrad

Sergio_A_Intel
Employee
430 Views

Hi cola,

Were you able to run the code correctly? What were your results after changing the baudrate?

Sergio

0 Kudos
KStrz
Novice
430 Views

Hi !

I am running code using Intel XDK IoT edition.

Results after running code - the same ;/

0 Kudos
Sergio_A_Intel
Employee
430 Views

Hi,

Is that the full error log, if not post the full log. I ran the same code and also received

444644264675 SerialPort /dev/ttyACM0

1444644264761 Connected /dev/ttyACM0

I didn't receive an "Illegal instruction" error, I received a "undefined" error plus some other error lines. Have you tried to run the code directly from Linux instead of the XDK?

Sergio

0 Kudos
Carlos_M_Intel
Employee
430 Views

Hi cola19,

Do you have updates in this?

Could you attach the full error log?

What is the outcome of running uname –a?

Which XDK version are you using?

Did you try to run the code from Linux side?

Kind regards

Charlie

0 Kudos
Reply