Closed frankvanbever closed 4 years ago
Can't you reset (eg. DTR RTS) the serial port on start-up, and capture that on the controller? That way, there shouldn't be partial data. I'm unsure whether you can actually capture such signals on de Arduino though, since they use an FTDI.
It's still useful to handle this error though, but it may fail less often.
I know from experience that errors at startups can be frequent (sometimes had to start 4-5 times before I had complete data on startup), and that it can also happen at random moments during execution. I think the program should check every time that the data is complete, for safety. We cannot assume (especially with serial communication) that we received the data without any problem.
Might also be useful to add a flush() in the arduino code to make sure the transmission is complete, might avoid some failures on the python side.
flush might be good for the python code, but it pauses the microcontroller
@TThetier @rubdos can you take another look at everything please? I've got a whole bunch of commits lined up in this PR.
All the commits look really good, but small concerns :
* What do we do when there is an error in decoding ? Do we just assume we can do without printing this data (I guess if we receive and plot a lot of datas per second, we can do without 1 or 2 batches of data) and send nothing and just hope the communication will go back to normal, or do we decide we absolutely need everything and therefore no failure in communication is acceptable ?
Can't we track both errors and correct condition? You could compute the error rate over time, and trigger some alarm when it raises over like 1 error/second, or say over 5% of all messages on a second.
At startup it's possible that we receive incomplete serial data. We need to account for this. We'll need to determine what level of errors are tolerable here. For testing purposes now I would stop the application so we get immediate feedback if this occurs more than once.
Signed-off-by: Frank Vanbever frank.vanbever@essensium.com