rwaldron / johnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.
http://johnny-five.io
Other
13.26k stars 1.76k forks source link

Hangup on start. #110

Closed divanvisagie closed 11 years ago

divanvisagie commented 11 years ago

After starting the ready event never fires , I would blame the firmata version but its the same as what I've used in the past . Running OSX 10.8 , firmata 2.2 installed with Arduino IDE 1.0.2

1364059764367 Board Connecting... 1364059764419 Serial Found possible serial port cu.usbmodemfa1311 1364059764421 Board -> Serialport connected cu.usbmodemfa1311 (get stuck here)

Firmata is working , tested using Firmata Test OSX app

however the JS version if firmata seems to not work as well so the problem may lie with firmata.js.

divanvisagie commented 11 years ago

Crisis seems to be resolved:

Steps taken:

drop to node 0.8.x Cleaned out node_modules folder in home directory ( firmata required sudo to remove so that was probably an issue ) clean j5 install

twalker commented 11 years ago

I'm running in to the same issue on Linux Mint Nadia (Ubuntu 12.04):

    board = new five.Board();
    board.on('ready', function() {
        console.log('does not fire');
    });

even though the Arduino Uno R3 is connected:

    Board Connecting... 
    Serial Found possible serial port ttyACM0
    Board -> Serialport connected ttyACM0

I've tried different Arduino IDE versions and am running StandardFirmata. I'm currently running Arduino IDE v1.02 since that version has worked for me in the past. I've set permissions on the device--i.e. sudo chmod a+rw /dev/ttyACM0. I even bought another Arduino board to verify I hadn't fried the board somehow.

I'm running node v0.10.2. WIll try downgrading to node 0.8.x :~(

divanvisagie commented 11 years ago

@twalker Did you try cleaning the node_modules folder first? Would be nice to narrow this problem down a bit

twalker commented 11 years ago

Deleting node_modules doesn't fix it, and I'm running johnny-five examples from a cloned repo. No matter which led example I run with a single led light in pin 13 is:

  3 blinks..pause..2 blinks..pause..3 blinks

I'm sure that's a meaningful pattern, I should RTFM.

rwaldron commented 11 years ago

@twalker can you list out your environment? I have:

https://dl.dropbox.com/u/3531958/Firmata.tar

divanvisagie commented 11 years ago

Ok, well I upgraded to v0.10 and had the issue again , reverting to 0.8 solved it once more , so the problem seems to lie with the change in node version ( this is with both firmata 2.2 and 2.3.1 ). Interestingly the behaviour is the same as that of a board that doesn't have firmata loaded on it. Anyway I'm going to reopen this issue on the account that it doesn't always seem to work with the newer node version.

rwaldron commented 11 years ago

@divanvisagie I made a mistake, running with v0.10.0 does hang on connection. I have no idea where to begin looking, but I'll report back when I know more.

divanvisagie commented 11 years ago

@rwldrn Well that explains it then , I think the problem lies in the js implementation of firmata, when I first had the problem I tried using firmata directly so that I could manually select the board , and that hung up too.

rwaldron commented 11 years ago

@divanvisagie I've boiled it down to something between node-firmata (let's just call it that haha) and node-serialport, but nothing has changed in node-firmata in 7 months

twalker commented 11 years ago

Thanks for the help, sorry for the delay. Here are my specs

I'll try the StandardFirmata version from your dropbox, thank you...

twalker commented 11 years ago

FWIW, I had no luck with the StandardFirmata from @rwldrn above.

rwaldron commented 11 years ago

@twalker yes, I had made a mistake in my initial diagnosis ;)

I've filed this as well: https://github.com/jgautier/firmata/issues/17

divanvisagie commented 11 years ago

@twalker , as a temporary solution you could use this https://github.com/isaacs/nave. I am also closing this issue on the account that the problem lies with node-firmata and not johnny-five.

rwaldron commented 11 years ago

@divanvisagie thanks for your diligence and all around support on this, hopefully we can get firmata issues resolved soon. I have confidence in @jgautier :)

twalker commented 11 years ago

@divanvisagie Thank you for pointing out nave--it's very useful. The board "ready" event is firing for me with node v0.8.17.

rwaldron commented 11 years ago

@twalker @divanvisagie great news, @jgaultier landed my patch just now that I believe will fix this issue. https://github.com/jgautier/firmata/pull/18

I've reopened so we can get some testing going :)

rwaldron commented 11 years ago

See also https://github.com/joyent/node/issues/5098

jonlong commented 11 years ago

Confirmed that this fixes the hanging issue for me and the 'ready' event is fired with v0.10.2.

twalker commented 11 years ago

The 'ready' event is firing for me also. Thanks for the tenacity.

jenkinslight

rwaldron commented 11 years ago

YES!!

rwaldron commented 11 years ago

@twalker https://twitter.com/rwaldron/status/322163232599048192 (couldn't find you on twitter)

rwaldron commented 11 years ago

I have not encountered this issue since the latest Firmata changes, closing. (if anyone has this issue still, please post here!)

ajfisher commented 11 years ago

Hi - there might be a regression here. Under Ubuntu 12.04 using node. 0.10.22 with simply an npm install johnny-five (all modules cleaned just for good measure). As such latest node serialport etc comes down as part of that.

Under this config simply to try a J5 "hello world"

var five = require("johnny-five"),
    // or "./lib/johnny-five" when running from the source
    board = new five.Board();

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

  // Create an Led on pin 13 and strobe it on/off
  // Optionally set the speed; defaults to 100ms
  (new five.Led(13)).strobe();

});

Will hang after connection. This is running standard firmata on an Arduino Diecimila and the equivalent code in Python using pyFirmata works absolutely fine so there's nothing wrong with firmata, versions of, or the arduino in this instance. Has to be something to do with node / j5 / serialport...

Any thoughts on this?

I haven't tried going backwards to node 0.8.x as some have suggested in this thread as it had appeared to be resolved. I'm going to attempt to do the same under OSX and see if that works and will report back any findings there.

ajfisher commented 11 years ago

On OSX using Node 0.10.4 it all works fine. Fresh install of node, upgraded to 0.10.4 under Linux Ubuntu still no joy.

ajfisher commented 11 years ago

Apologies for the thread bombing - but hopefully this helps someone else along the way which is why I'm documenting this final comment on the matter.

There is a difference in drivers under Ubuntu (possibly others) linux for Duemilanove style boards and the newer Uno style boards. What this means is that Johnny Five does not seem to work with any version of node if you're using a Duemilanove board. Switch to a more modern Uno based on and it works with the same versions I tested against (0.8.17, 0.8.22, 0.10.4).

If anyone happens to have older boards to test this with it would be great to see if this is repeatable in order to try and diagnose what's going on.

rwaldron commented 11 years ago

When you say "hang", does that mean literally nothing happens? Can you screenshot? It's possible that this is a result of the new board-specific pin capability mapping in Johnny-Five.

ajfisher commented 11 years ago

I'll get a screen shot over later as I'm no where near the machine, but basically it never hits the board on ready state. It seems to detect and connect to the device just never gets past the connection point.

Just to be clear. The same code, same board and same firmata works fine under OSX - it's only on Linux it's an issue and only on the non Uno board. On 5 Jul 2013 01:30, "Rick Waldron" notifications@github.com wrote:

When you say "hang", does that mean literally nothing happens? Can you screenshot? It's possible that this is a result of the new board-specific pin capability mapping in Johnny-Five.

— Reply to this email directly or view it on GitHubhttps://github.com/rwldrn/johnny-five/issues/110#issuecomment-20482848 .

rwaldron commented 11 years ago

It seems to detect and connect to the device just never gets past the connection point. ... The same code, same board and same firmata works fine under OSX - it's only on Linux it's an issue

Do me a favor? Can you try running this same program as sudo? The compiled serialport bindings don't have sufficient permission to open /dev/*

ajfisher commented 11 years ago

Apologies - didn't have much time near machines over the weekend.

So that was one of the first things I tried as I've had this problem before. My user is part of the dialout group so I expected this wouldn't be a problem. However sudo didn't work and neither did explicitly chmod-ing /dev/ttyUSB0 once it was connected.

Also, for some additional info. I tried this on another Ubuntu 12.04 machine which doesn't have arduino IDE on it and no user permissions configured for the devices (ie no dialout group membership etc). When I did this I got a correct permissions error when attempting to run the code without access to /dev/ttyUSB0 AND /dev/ttyACM0 (ie it was consistent across the duemilanove and Uno arduinos).

Once I ran as sudo (or chmod-ed device permissions) I got the same result as I've been experiencing. Everything works fine with an Uno class arduino but stops dead after connection on the Duemilanove.

Final FYI: I was worried that it might be the Duemilanove I was using and I couldn't find another to test (they are all embedded in devices) so I tried controlling it via a python script using pyFirmata - it works as expected so I'm reasonably confident it's not something to do with the arduino itself.

Very odd behaviour though as I really didn't think there was that much difference between the two MCUs.

Andrew Fisher http://about.me/ajfisher/bio

On Sat, Jul 6, 2013 at 1:50 AM, Rick Waldron notifications@github.comwrote:

It seems to detect and connect to the device just never gets past the connection point. ...

The same code, same board and same firmata works fine under OSX - it's only on Linux it's an issue

Do me a favor? Can you try running this same program as sudo? The compiled serialport bindings don't have sufficient permission to open /dev/*

— Reply to this email directly or view it on GitHubhttps://github.com/rwldrn/johnny-five/issues/110#issuecomment-20525649 .

rwaldron commented 11 years ago

@ajfisher can you run this and post the result: https://gist.github.com/rwldrn/5792793

ajfisher commented 11 years ago

Will do tonight when I'm back home. Will get you output on Uno and Duemilanove.

Andrew Fisher http://about.me/ajfisher/bio

On Mon, Jul 8, 2013 at 11:09 AM, Rick Waldron notifications@github.comwrote:

@ajfisher https://github.com/ajfisher can you run this and post the result: https://gist.github.com/rwldrn/5792793

— Reply to this email directly or view it on GitHubhttps://github.com/rwldrn/johnny-five/issues/110#issuecomment-20581336 .

ajfisher commented 11 years ago

screenshot from 2013-07-08 20 53 15 Gist results shortly. In the mean time more weirdness. I just upgraded to libusb-1.0-0 including use of libusb-1.0-0-dev (installed using a sudo apt-get install...). This is not a standard package installed with 12.04 ubuntu but is in universe as an option. Removal of it creates the same effect I mentioned previously and another ubuntu machine without it installed exhibits the behaviour previously noted.

Once I upgrade to the new libusb I can get the ready event to fire and Pin 13 LED blinking away merrily on the Duemilanove. Awesome...

Right up to the point I close my node application. Issuing a process.exit() from the repl looks as though it is closing everything down appropriately. I can connect on the same USB device via a different application properly so it would appear as though it's closed but something is still locking up on the node side.

IE I CAN do this: Run node firmata test, connect, get blinking light, exit. Fire up python firmata, connect get blinking light.

I CAN'T do this: Run node firmata test, connect, get blinking light, exit. Fire up node firmata again, connect and get blinking light.

Screen shot below - including the timeout that occurs.

screenshot from 2013-07-08 20 53 15

The only way it would appear to get this to work in node is to exit, unplug the arduino, run the node app again and then reset it AFTER the connection has happened (at the point where it's attempting to time out).

This is totally consistent.

For the record - multiple Uno devices still work exactly as they did before (prior to the lubusb update) so they haven't changed behaviour in any way as a result.

rwaldron commented 11 years ago

Thanks for all of this info (and your patience while working through the issue). Unfortunately, I won't have time to work through all of these STRs until later this week.

ajfisher commented 11 years ago

No worries at all. Now I have a semi work around and can see what's going on - if I see it crop up on nodebots day I can tell people what to do about it. FYI - once it is running, so long as you don't exit the node process it will seem to run entirely fine without any issues.

Andrew Fisher http://about.me/ajfisher/bio

On Tue, Jul 9, 2013 at 12:55 AM, Rick Waldron notifications@github.comwrote:

Thanks for all of this info (and your patience while working through the issue). Unfortunately, I won't have time to work through all of these STRs until later this week.

— Reply to this email directly or view it on GitHubhttps://github.com/rwldrn/johnny-five/issues/110#issuecomment-20610958 .

ajfisher commented 11 years ago

So I think this issue may be resolved now with the upstream firmata changes made under the PR for https://github.com/jgautier/firmata/pull/30

divanvisagie commented 11 years ago

@ajfisher I would like to close this if you can confirm the issue resolved.

ajfisher commented 11 years ago

As far as J5 is concerned I think this is all good. I think there is a residual issue with the way the serial port gets closed down but that's not a Johnny Five issue. I'll pick that up separately in firmata / serialport.

:+1: for closing.