does anyone know a way to clear the UART buffer when starting a script in micropython?
A few weeks ago I was trying to write data received on my UART to an mjpeg video (trying to see what kind of latency I could expect). Problem was as soon as I tried to read from the UART buffer, the OpenMV IDE would just stop working, it never finished recording the video (I was using a modified version of the example video record script). Plus the frame rate was awful (at most 1 fps). After a few hours (trying to figure out a minimum working example of this failure to post here) I solved the problem by increasing the size of my receiving bytearray for UART data from 300 to 10000. It turns out it also worked if I simply turned on the OpenMV cam before turning on the system sending data over UART.
Now I’m implementing on my real system, and I’m encountering the same problem. My system is receiving 270 bytes per second. Even with my bytearray set to 10000 it doesn’t work (and trying 20000 gives me a memory allocation error). If I power on the OpenMV cam before I power on the transmitting UART device, it seems to work just fine, but if I power them both up at the same time the OpenMV IDE will fail. The first time I hit the “play” button it simply disconnects, the second time it will hang. Any ideas for a more robust solution to this than simply telling my transmitting system to wait a bit after power up before sending?