Serial communication using Firmata - Arduino sometimes gets wrong value

Hello,

I have a strange behaviour that I cannot explain yet - maybe some of you have already seen something similar.

I have setup a bidirectionnal communication using Firmata between my Arduino (mega clone) and a python program. Serial communication is set at 57600 bauds (firmata default).

Everything works OK except for some values sent by the computer to the Arduino - those values (4 bytes float sent as 8 bytes sysex firmata messages) are always correct when sent from Arduino to the computer, but on the other way around, some values get corrupted (I would say that 1 on 10 gets corrupted - looking at the bits I don't see any clear pattern, everything is mixed up, though the wrong values tend to repeat themselves). If I resend the same value, it eventually makes it to the Arduino untouched...

I typically send a float from the computer to the Arduino, and then the Arduino sends it back to the computer at regular interval (among other things). All the communication handling on the Arduino side happens in the main loop function (so no concurrency problem - even is I am using a timer thread which does read - not write - the values with which I have the problem).

I will try using a hand-made protocol instead of firmata (which is of little use for me so far) and/or get a simple reproducer code.

Is it necessary to add a checksum mechanism over serial communication ? Are there any good library that would provide reliable communication be

Thanks for your help,

G

I will try using a hand-made protocol instead of firmata (which is of little use for me so far)

Good idea.

I typically send a float from the computer to the Arduino, and then the Arduino sends it back to the computer at regular interval (among other things).

That is NOT what Firmata does. If you are diddling with the Firmata sketch, you are likely your own worst enemy. If you are diddling with the Firmata sketch, and having problems with the diddled-with sketch, you probably should post it.

Hi PaulS,

I am not sure to follow you - how am I "diddling with the firmata sketch" ? I send back and forth SYSEX messages - those contain manually serialized data (in my case floats).

The messages are formatted by the Firmata library on the Arduino side and pyFirmata on the computer side.

I'll have more details tomorrow...

Hand-written protocol over Serial works like a charm. I didn't understand what I was doing wrong though...