hardbap / firmata

A Ruby implementation of the Firmata protocol.
MIT License
42 stars 23 forks source link

Can't connect to arduino board, keeps looping in read_and_process #10

Open rafmagana opened 11 years ago

rafmagana commented 11 years ago

Here's my setup:

NOTE: I tried to downgrade to 2.2 (as suggested in the README file) but the Arduino app (v1.0.5) threw some errors (a lot of "was not declared in this scope" for TOTAL_PORTS, Firmata, reportPINs, etc) and I wasn't able to do it.

I know Firmata is working in the Arduino because I used a software called firmata_test (http://firmata.org/wiki/Main_Page#Firmata_Test_Program) and the arduino_firmata gem and was able to change the state of the pins.

Here's the code I'm using:

require 'firmata' # v0.1.1

# tried with /dev/tty.usbmodemfa131 too, same results
board = Firmata::Board.new('/dev/cu.usbmodemfa131')

# this does nothing, it gets stuck there, I need to Ctrl-C
board.connect

I put some "puts" in the connect method (https://github.com/hardbap/firmata/blob/v0.1.1/lib/firmata/board.rb#L96), it never executes once('report_version', ->() do and it keeps looping in until connected? forever.

I tried it installing Ubuntu 12.04 in a VirtualBox, same results, even though some linux users have reported this gem works for them.

Any idea?

hardbap commented 11 years ago

@rafmagana I have only tested on Firmata 2.2 with Arduino v 1.0.1. There was a known issue with the Board never getting into ready state with StandardFirmata 2.3.

Question: if the arduino_firmata gem is working for you why not stick with that?

The @hybridgroup has an awesome project called artoo which has forked and enhanced the firmata gem. Maybe give their version a try?

rafmagana commented 11 years ago

First, thanks for your quick response.

Second, actually, I work for @hybridgroup :) I'm trying to make Artoo work in a Mac using Firmata, and even though we have forked and enhanced your gem we're having the same problem in Mac (at least in mine). I don't want to switch to arduino_firmata because your gem is already working on Linux and don't want to change the whole implementation to use arduino_firmata (we'll do it if we don't any other option of course) and because I haven't been able to upload Firmata 2.2 to my Arduino Leonardo, how do you upload it?

Thanks!

hardbap commented 11 years ago

On my MBP I upload StandardFirmata 2.2 to my Uno via USB using Arduino v. 1.0.1. I've never played around with anything else.

I don't have my board with me to test but it could be that Board#connect just needs to be rewritten. #connect was written specifically to the 2.2 interface so I'm betting that something has changed. I don't really like my event_spitter gem and the once blocks are ugly too.