Hi,
At the end, in order to figure out all the weridnesses regarding the apparently different behavior of the Arduino on different platforms, I only need to answer a simple question, well two simple questions:
every time it accepts a connection on the serial port, or only when it is powered up or reset?
send in Pd to the [arduino] object) supposed/expected to cause the arduino to reset?
This is slightly OT but it is relevant for working with [arduino] in Pd.
Thanks m.
On 2011-06-15 07:13, Matteo Sisti Sette wrote:
Hi,
At the end, in order to figure out all the weridnesses regarding the apparently different behavior of the Arduino on different platforms, I only need to answer a simple question, well two simple questions:
- Does the StandardFirmata firmware send the firmware name and version
every time it accepts a connection on the serial port, or only when it is powered up or reset?
From looking at the code it only sends the digital pins on startup, not the version. Probably it's the Pd patch that asks for the version.
- Is the action of opening the connection (i.e. the "open" message you
send in Pd to the [arduino] object) supposed/expected to cause the arduino to reset?
that might depend on the driver for the FTDI chip, which is different from a regular USB serial connection. You might want to try a teensy instead of an arduino as it uses standard USB serial protocol.
Martin
On 06/15/2011 04:02 PM, Matteo Sisti Sette wrote:
On 06/15/2011 03:03 PM, Martin Peach wrote:
Probably it's the Pd patch that asks for the version.
Oh, that's strange. I've searched in depth inside the [arduino] abstraction and I can't find anything that is possibly doing that!
Definitely, it is not the patch. I've placed a [print] to print everything that is being sent to [comport] and the only thing that it is being sent to it is the "open" message.
Tha Arduino board is sending the version information when Pd connects to it, whether it is at startup (because of a reset) or at connecting.
On 06/15/2011 04:25 PM, Matteo Sisti Sette wrote:
Tha Arduino board is sending the version information when Pd connects to it, whether it is at startup (because of a reset) or at connecting.
I guess it is this, in Firmata.cpp:
void FirmataClass::begin(long speed) { #if defined(__AVR_ATmega128__) // Wiring Serial.begin((uint32_t)speed); #else Serial.begin(speed); #endif blinkVersion(); delay(300); printVersion(); // <-- this! printFirmwareVersion(); }
This function is called at startup.
So, if arduino only sends this at startup, and if startup is not guaranteed to (re)happen when connecting to it, what is the correct way to ensure that you send the necessary configuration messages (such as pinMode stuff) just after opening the port? Other than putting an arbitrary delay I mean.
If you just send the pinModes immediately after the "open" messages, you're almost sure they're lost, but there doesn't seem to be any safe way to be informed of when you can send them...
Any idea? Or do I have to put a few second delay and hope it is always enough?
The "open 1" message is only triggered by sending the "info" message, but then the same problem raises: when do I send the "info" message?
Thanks m.
Matteo Sisti Sette wrote:
So, if arduino only sends this at startup, and if startup is not guaranteed to (re)happen when connecting to it, what is the correct way to ensure that you send the necessary configuration messages (such as pinMode stuff) just after opening the port? Other than putting an arbitrary delay I mean.
I would remove the (annoying) autoreset feature from the arduino board by cutting the "reset-en" trace. No more stupid resets.
On 06/15/2011 05:08 PM, Charles Goyard wrote:
I would remove the (annoying) autoreset feature from the arduino board by cutting the "reset-en" trace. No more stupid resets.
Would that ensure that I could send a pinMode or analogIns message _immediately_ after "open" and rely on that it would be received by the arduino?
Matteo Sisti Sette wrote:
I would remove the (annoying) autoreset feature from the arduino board by cutting the "reset-en" trace. No more stupid resets.
Would that ensure that I could send a pinMode or analogIns message _immediately_ after "open" and rely on that it would be received by the arduino?
That would ensure you're not talking to the Arduino's bootloader.
Opening the port reboots the Arduino. From reading the bootloader code, it does not pass the bytes received before its timeout to the application. So you want to avoid the bootloader.