Firmata closes serial connection (refiled from Johnny-Five #13

Closed
rwaldron opened this Issue Aug 14, 2012 · 14 comments

Projects

None yet

6 participants

Collaborator

Originally filed here: rwaldron/johnny-five#53

First off, rad project. I'm hoping someone can steer me towards the light...

Attempting to run the demo code: (

var five = require("johnny-five"),
    board = new five.Board();

board.on("ready", function() {
  (new five.Led(13)).strobe();
});

Which fails with:

Connecting...�
Serial� Found possible serial port� ttyACM0
Board -> Serialport� connected�
Board <- Serialport ready�
Repl� Successfully Connected�
firmata > �Board� Closing connection to board, serialport
/home/usernamehere/projects/johnny-five/node_modules/firmata/lib/firmata.js:13341: Uncaught TypeError: Cannot set property 'mode' of undefined

ArchLinux
NPM version 1.1.46
Node version v.0.8.5
Arduino Uno via USB

thanks in advance...

Member

this usually indicates an error when starting up firmata it might be a good feature to add error handling at this line. https://github.com/rwldrn/johnny-five/blob/master/lib/board.js#L110 that function actually receivs any errors from the serial port as the first argument so you could use that error in the callback. this wouldnt fix the problem but atleast give us insight into the error that is happening.

Member

yep looks good.

On Sun, Aug 19, 2012 at 7:54 PM, Rick Waldron notifications@github.comwrote:

@jgautier https://github.com/jgautier looks good?
https://github.com/rwldrn/johnny-five/blob/master/lib/board.js#L110-111


Reply to this email directly or view it on GitHubhttps://github.com/jgautier/firmata/issues/13#issuecomment-7859785.

Howdy guys, thanks for the productive discussion. Unfortunately after updating I get the same error. Super bummed.

Heres an exhaustive list of OS's I've tried using an Arduino Uno w/ Firmata 2.2.

Works on a fresh Mountain Lion install on a 2011 13" MBP:

$ git clone https://github.com/jgautier/firmata.git
$ npm install
$ cat examples/blink.js # check that the serial port matches
$ node examples/blink.js
blink start ...
connected

Fails On an ArchLinux VM under VMWare Fusion:

$ git clone https://github.com/jgautier/firmata.git
$ npm install
$ lsusb | grep 'Arduino'
Bus 002 Device 014: ID 2341:0001 Arduino SA Uno (CDC ACM)
$ ls /dev/ | grep 'ttyA'
ttyACM0
$ emacs -nw examples/blink.js # change USB->Serial device to /dev/ttyACM0 (also tried /dev/bus/usb/002/0015')
$ node examples/blink.js
blink start ...
connected
/Users/myname/projects/firmata/examples/blink.js:379: Uncaught TypeError: Cannot read property 'major' of undefined

Fails on a ArchLinux VM under VMWare ESXi 4.2 on a Dell 2950 Server

$ # as above...

Fails on Ubuntu 12.1 VM:

$ # same steps, changing to /dev/ttyACM0 (and even /dev/tty.ACM0 & '/dev/bus/usb/002/0015' )
$ node examples/blink.js
axconfig: port 1 not active
axconfig: port 1 not active

So this is where I'm stuck. Just as I moved down the ladder, so to speak, from Johnny-five -> Firmata .... should I do the same and see if another package is failing me?

edit - It seems the error occurs on my Macbook on occasion - but it's the result of my serial modem changing to 'tty.serialmodemfa131' from the default. So perhaps Firmata doesn't like the Linux TTY filename ('/dev/ttyACM0' and '/dev/bus/usb/002/0015' )

Member

I just changed the blink example to output an error if there is one. I didnt test this but I think it should work. Try the ones that were failing again and see if you get any errors output. Seems like it has to do with running it on a VM.

Just to update, I now can use Firmata (but not on Ubuntu).

The issue was I was not in the correct group for ArchLinux to access the serial port - despite it seeing the device in

$ echo "foobar" > /dev/ttyACM0
permissions error (too lazy to cut+paste) 
$ sudo gpasswd -a <user> uucp #(and then reboot)

On my UbuntuVM, I still get the same:

$ node examples/blink.js
axconfig: port 1 not active
axconfig: port 1 not active

My VM settings are to pass through this USB device from the host to a particular VM.

I'll keep mucking about...

Member
jgautier commented Sep 6, 2012

What is now preventing you from using johnny-five?
On Sep 5, 2012 6:06 PM, "Steven" notifications@github.com wrote:

Just to update, I now can use Firmata (but not Johnny-five...).

The issue was I was not in the correct group for ArchLinux to access the
serial port - despite it seeing the device in

$ sudo gpasswd -a uucp #(and then reboot)


Reply to this email directly or view it on GitHubhttps://github.com/jgautier/firmata/issues/13#issuecomment-8319294.

Within ArchLinux it really doesn't post an error.

screenshot

Occasionally, I get dumped to a firmata prompt. But trying to pass led.on() or similar didn't work as I had hoped
screenshot #2


More Ubuntu Steps:

$ sudo usermod -a -G dialout myusername
$ sudo chmod a+rw /dev/ttyACM0
# steps via: http://blog.markloiseau.com/2012/05/install-arduino-ubuntu/

I then opened the official Arduino client and uploaded a 'blinking leds' file to make sure everything worked. It did, so I reuploaded the StandardFirmata file. But I still get the axconfig error...

Ubuntu (continued)


Trying Johnny-five on Ubuntu now results in the same thing as ArchLinux... the TX light stays lit but pin13 doesn't cycle...

screenshot

$ cat /dev/ttyACM0

screen
So you can see the serial connection is made and something is going across the wire...

But now that is Firmata is working well, I'll move future problems to Rwldrn's repo.

Thanks for the help so far.

@louisremi louisremi added a commit to louisremi/firmata that referenced this issue Jan 6, 2013
@louisremi louisremi [fix #13] Request REPORT_VERSION & QUERY_FIRMWARE 1c02dc1
danab commented Jan 30, 2013

I am getting an identical error to the first issue. Ubuntu 12.04

Attempting to run:

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();

});

Results in:

➜  j5  node hello.js              
1359514538930 Board Connecting... 
1359514539026 Serial Found possible serial port ttyACM0
1359514539027 Board -> Serialport connected ttyACM0
1359514539027 Board  
1359514539027 Repl Successfully Connected 
>> /home/username/nodeduino/j5/node_modules/johnny-five/node_modules/firmata/lib/firmata.js:13341: Uncaught TypeError: Cannot set property 'mode' of undefined

I used the StandardFirmata that came with the arduino IDE (not sure of version number) and then replaced with 2.2 from the firmata site. Both exhibited the same problem.

Being new to both johnny-five and arduino (and hence firmata) I'm not sure how to diagnose the location of the problem...any thoughts? Thanks so much

Member
jgautier commented Jul 3, 2013

considering this is 5 months old im closing. please reopen if there is still an issue.

@jgautier jgautier closed this Jul 3, 2013
Collaborator
rwaldron commented Jul 3, 2013

The solution to this problem is that Linux users must run programs as sudo, since serialport doesn't have sufficient permissions to open the /dev/* port

I had the same issue in Windows 7, you have to run node.js as administrator

I solved this problem in Arch Linux by adding the user to the "tty" system group, which gives access to "/dev/ACMx"

  sudo gpasswd -a <user> tty

It worked after I logged out and back in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment