rwaldron / galileo-io

Intel Galileo & Intel Edison IO Plugin for Johnny-Five
http://johnny-five.io
MIT License
101 stars 26 forks source link

new io.Gpio(this.addr) fails #20

Closed andrewfaria closed 9 years ago

andrewfaria commented 9 years ago
root@edison:~# node johnny.js

/home/root/node_modules/edison-io/node_modules/galileo-io/lib/mraa.js:66
    state.io = new io.Gpio(this.addr);
               ^
Error: Illegal arguments for construction of _exports_Gpio
    at new Pin (/home/root/node_modules/edison-io/node_modules/galileo-io/lib/mraa.js:66:16)
    at Galileo.<anonymous> (/home/root/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:160:16)
    at Array.map (native)
    at new Galileo (/home/root/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:156:24)
    at Object.<anonymous> (/home/root/johnny.js:5:34)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
root@edison:~#

Code:

var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({ io: new Edison() });

board.on("ready", function() {
  var led = new five.Led(13);
  led.blink();
});
rwaldron commented 9 years ago

Thanks!

Here's one thing I need to know and another thing you can try:

  1. Run this and tell me what the result is: node -e 'console.log(require("mraa").getVersion());'
  2. Run:
echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf;
opkg update;
opkg install libmraa0;

... and then try your script again.

andrewfaria commented 9 years ago

mraa version: v0.5.2-1-gfdb11d9 mraa update output: Package libmraa0 (0.5.2.1) installed in root is up to date.

Same error after update. :(

rwaldron commented 9 years ago

The first part is great. The second is a bummer. Ok next question (sorry I forgot ask this the first time): Are you using the Edison + Arduino expansion board or Edison + Mini-Breakout?

andrewfaria commented 9 years ago

I have both, but started with the expansion board.

rwaldron commented 9 years ago

Ok, good. I have both as well. I'm going to hook up the Edison + Arduino Expansion and try to reproduce. I will post back as soon as I know more.

andrewfaria commented 9 years ago

I also flashed this one with the latest image. I'll try the mini while you try the big boy. ;)

andrewfaria commented 9 years ago

Works like a charm on the mini (before firmware upgrade).

andrewfaria commented 9 years ago

Failed on the mini after I updated libmraa. :(

rwaldron commented 9 years ago

Can you paste the error?

andrewfaria commented 9 years ago

I've confirmed the mraa javascript lib (by itself) is working.

Here's the error from johnny.js:

root@edison:~# node johnny.js

/home/root/node_modules/edison-io/node_modules/galileo-io/lib/mraa.js:66
    state.io = new io.Gpio(this.addr);
               ^
Error: Illegal arguments for construction of _exports_Gpio
    at new Pin (/home/root/node_modules/edison-io/node_modules/galileo-io/lib/mraa.js:66:16)
    at Galileo.<anonymous> (/home/root/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:160:16)
    at Array.map (native)
    at new Galileo (/home/root/node_modules/edison-io/node_modules/galileo-io/lib/galileo.js:156:24)
    at Object.<anonymous> (/home/root/johnny.js:4:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

johnny.js

var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  var led = new five.Led(13);
  led.blink();
});
rwaldron commented 9 years ago

This is strange, I just copied your example exactly as shown and it worked as expected.

So try this:

andrewfaria commented 9 years ago

The update for Johnny-Five worked! :) Thank you for the super-sonic responses.

rwaldron commented 9 years ago

Looks like I need to revisit the board detection vs. explicitly defined IO instance creation. Thanks for the report and for your patience in working through it :)