LXJS / training-nodebots

MIT License
1 stars 5 forks source link

Any problems with the nodebot-workshop? #32

Open olizilla opened 10 years ago

olizilla commented 10 years ago

Hi LXJS! If you signed up for the NodeBots workshop session, we made https://github.com/tableflip/nodebot-workshop to help you learn the basics of the johnny-five api before the event. We'll go through it on the day, but we only have 2 hours to build a thing, so the more you know before-hand the more we can get done on the day.

Apologies if you received hundreds of emails about this already, but we're super excited about it. We updated the nodebot-workshop over the weekend to make some improvements. It's ready for you to use, but if you do have any problems with it, or just get stuck, let us know. You can add a comment on this issue.

 npm install nodebot-workshop
marionzualo commented 10 years ago

Hi,

I started to do the nodebot-workshop. I solved the 8th exercise and according to nodebot-workshop the solution passed yet I received the following message:

marios-mbp:nodebot-workshop marionzualo$ nodebot-workshop verify 08-remote-temperature.js 
1403365729619 Device(s) /dev/cu.usbserial-FAKEID 
1403365730028 Connected /dev/cu.usbserial-FAKEID 
1403365730029 Repl Initialized 
>> Please wait while your solution is tested...

# PASS

Your solution to Remote Temperature passed!

Here's the official solution is if you want to compare notes:

/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3392
        marker.loc = {
        ^
TypeError: undefined is not a function
    at createLocationMarker (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3392:9)
    at /usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3608:26
    at parseAdditiveExpression (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:1807:20)
    at /usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3609:38
    at parseShiftExpression (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:1824:20)
    at /usr/local/

I tried running it again and I had the following output (the odd thing is the error message changes!):

marios-mbp:nodebot-workshop marionzualo$ nodebot-workshop verify 08-remote-temperature.js 
1403365916356 Device(s) /dev/cu.usbserial-FAKEID 
1403365916765 Connected /dev/cu.usbserial-FAKEID 
1403365916765 Repl Initialized 
>> Please wait while your solution is tested...

# PASS

Your solution to Remote Temperature passed!

Here's the official solution is if you want to compare notes:

/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3245
            } else if (isWhiteSpace(ch)) {
                       ^
TypeError: undefined is not a function
    at scanComment (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3245:24)
    at /usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3606:17
    at parseLogicalORExpression (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:1946:20)
    at /usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3609:38
    at parseConditionalExpression (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:1966:16)
    at /usr/local/l

I ran the command once again and I got yet another error message:

marios-mbp:nodebot-workshop marionzualo$ nodebot-workshop verify 08-remote-temperature.js
1403366048145 Device(s) /dev/cu.usbserial-FAKEID 
1403366048553 Connected /dev/cu.usbserial-FAKEID 
1403366048554 Repl Initialized 
>> Please wait while your solution is tested...

# PASS

Your solution to Remote Temperature passed!

Here's the official solution is if you want to compare notes:

/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3391
        marker.range = [index, index];
        ^
TypeError: undefined is not a function
    at createLocationMarker (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3391:9)
    at /usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3608:26
    at parseRelationalExpression (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:1845:16)
    at /usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:3609:38
    at parseEqualityExpression (/usr/local/lib/node_modules/nodebot-workshop/node_modules/workshopper/node_modules/msee/node_modules/cardinal/node_modules/redeyed/node_modules/esprima/esprima.js:1863:20)
    at /usr/l

Is it an issue with my solution or with nodebot-worshop?

alanshaw commented 10 years ago

Weird - would you mind posting your solution?

marionzualo commented 10 years ago

My solution goes below:

var dnode = require('dnode');
var five = require('johnny-five');
var board = new five.Board();

board.on('ready', function () {
  var temperature = 0;

  sensor = new five.Sensor("A0");

  function analogToCelsius(analogValue) {
    return ((analogValue * 0.004882814) - 0.5) * 100;
  }

  sensor.on("data", function() {
    temperature = analogToCelsius(this.value);
  });

  var server = dnode({
    getTemperature : function (cb) {
      cb(temperature);
    }
  });
  server.listen(1337);
});