3 ms·
I have a few STM32 projects where I need bidir communication between the microcontroller and the PC. The microcontroller has on the order of 10-20kB of RAM tota
by magicalhippo 6y ago
I have a few STM32 projects where I need bidir communication between the microcontroller and the PC. The microcontroller has on the order of 10-20kB of RAM total and around 100kB of Flash.
After trying several other solutions I ended up with JSON over USB serial.
I tried several of the binary JSON-like variants, but they were all a PITA to port or ended up eating a lot of space, either in RAM or Flash or both. For this project I wasn't too concerned about message size or performance as such, as long as it could be read or generated in small portions.
I ended up adapting two JSON libraries, a one for parsing and for generating. The parser was SAX-like, so worked just fine for incremental parsing. Worked quite well, in total considerably smaller both in RAM and Flash than the alternatives.
- bradstewart 6y agoAn STM32 is several orders of magnitude more powerful than an 8051 (or a 6052) though.
- magicalhippo 6y agoSure but I wasn't after fast parsing, I was after a somewhat flexible data exchange format that didn't take a lot of space (both data and code), and ideally was easy to debug. A custom binary protocol would certainly be smaller but would take a lot more time to develop and debug.