AlexT-38 / OpenGEET_ECU_firmware

Open GEET Engine Control Unit firmware
GNU General Public License v3.0
1 stars 0 forks source link

Better string buffer class #18

Closed AlexT-38 closed 1 year ago

AlexT-38 commented 1 year ago

When logging, reports are formatted into a local String. This String is appended to another static String which is used as a buffer for writes to both Serial and SD card. Having two Strings limits the maximum size of the output buffer, and thus also the size of the report, and the number of channels and samples that can be logged. See issue #10 .

String is to be replaced with a custom string buffer class. To avoid rewriting all the logging code, the same append operators defined for String should be defined for the new class.

To handle report writes atomically, after a record is written, the writes must be committed. If the buffer has overrun, committing will reset the buffer back to the last commit. Committed data can be popped off the start of the buffer, with the data either copied to a char array, written to a Stream, or discarded.

The buffer could be circular, but this may cause an SD Card buffer write to be split into two operations, which would have a small write time penalty. Alternatively, the buffer could be linear, and have a function to move the data back to the start of the buffer at an opportune moment.