REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
|
Loading...
Searching...
No Matches
Style Guide
This page is a code style guide for the HybridController Firmware.
Entrypoints and Seperations
src/hybrid-controller.cpp
is the main entry point for regular usage.- All (unit/integration/etc) tests below
test/
are also entry points on its own. - Code is highly capsulated in different "modules" within the
lib/
directory.
Formatting
- The code generally uses 2 whitespaces as intend. However, clang-format shall be used.
- Use C++ features wisely. Don't end up in template hell.
Communication Concepts
- JSON lines as universal protocol for communicating with the microcontroller (basically for anything: Logging, Remote Procedure Calls, etc.). We therefore also stick to ASCII whenever possible.
- The USB serial console is always treated as an administrative interface. Reason: Whoever has access to the serial console also has physical access to the microcontroller.
Strings
- Prefer STL to Arduino libraries wherever possible, for instance prefer std::string over Arduinos String.
- Prefer Arduinos Printable interface over memory-intensive string serialization.
- Prefer to use JSON Custom Converters in favour of some
toJSON
methods.
The Heap in general
This code does not save on new
and malloc
calls. There is lot to improve here. Could employ more ETL instead of STL.
Strings/Buffer vs. Streams
TODO, write about
- Buffers such as ArduinoJSON with their document concept
- Streaming data which avoids in-memory preparation