I recently upgraded to Arduino 0017 which includes Firmata 2.1, and my projects that use Standard Firmata no longer work. I believe I have found the problem but wanted to see what people thought.
I'm using the Processing Arduino library to interface with Standard Firmata, and the first thing I had to do was change the serial speed from 115200 to 57600 since this is the new default speed in Firmata 2.1. Digital outputs began to work but digital and analog inputs still did not.
I finally found that the StandardFirmata.pde sketch now calls
Firmata.begin(57600) instead of calling
Firmata.begin(). This seems fine except that these two implementations of the
begin method in Firmata.cpp are
different. This difference is causing digital and analog input to not work on my Duemilanove.
Code:/* begin method for overriding default serial bitrate */
void FirmataClass::begin(void)
{
Serial.begin(57600);
blinkVersion();
delay(300);
printVersion();
}
/* begin method for overriding default serial bitrate */
void FirmataClass::begin(long speed)
{
blinkVersion();
#if defined(__AVR_ATmega128__) // Wiring
Serial.begin((uint32_t)speed);
#else
Serial.begin(speed);
#endif
delay(300);
printVersion();
printFirmwareVersion();
}
Note that in the no-arg version of
begin(), the call to
Serial.begin(57600) precedes
blinkVersion(). But in the begin method that takes a speed argument,
blinkVersion() is called
before the call to
Serial.begin(speed). This causes my Arduino to never send any inputs over the Serial line. There must be a timing issue here. When I change the order so that
blinkVersion() occurs after
Serial.begin(speed), everything works fine.
Short story: this can be fixed by reordering the
Firmata.begin methods to make them consistent or to have the examples call the no-arg version of
Firmata.begin().
Has anyone else had issues with using Firmata 2.1 included in Arduino 0017? I would think that anyone using any of the examples like StandardFirmata would have found them not to work...