Hey, my thoughts on this…
asyncio on the GUI side might be interesting for other reasons, although my impression is the GUI is very responsive despite the constant serial comms.
On the MCU side, I think there is a lot that could be done, but I think care should be taken to keep it separate from the “simple and generic” interface we have now. Any Arduino has a Serial object, but not all of them have timers that work in the same way, etc…
I know you like SAMD - I think on SAMD it should be possible to drive the SERCON using DMA, with almost no overhead to the main loop. But this will hardly be portable to other MCUs. So I think a good approach here could also be to write alternative “monitoring backends”, which can be kept separate from the main code (not wasting space and confusing the people not using them). The “pros” that want DMA-based monitoring for their MCU can then select from the available backends, or code their own.
I’m sure some people have been thinking about other channels than Serial (UDP on ESP32 for example, or MQTT, etc…). There could be backends for that too!
In terms of the existing SimpleFOC implementation, I would keep it simple, and keep it on Serial. This will be what 90% of users want when first testing it out, and what the less advanced users can realistically manage.
A possible optimization might be a binary mode for monitoring.
At the moment we send a bunch of 32 bit floats as ASCII. This incurs a penalty both in terms of ASCII conversion of the data, and sending some extra bytes.
I think converting to a binary format might improve the performance somewhat.
The ASCII format could be default, and we could keep it for the commander, but the binary format could be used by the monitoring when called from the SimpleFOC Studio…