Washington-Superbike / Superbike-Firmware

2 stars 3 forks source link

Add syslog feature #12

Open Chase-Arline opened 1 year ago

Chase-Arline commented 1 year ago

We should have a syslog feature, otherwise all of our beautiful print statements will be lost whenever we aren't directly wired to the Teensy. Imagine a race finishing, and our bike failed half-way through. The only data available is whatever is logged in the CSV files, but no debugging prints at all. The syslog feature works as described below.

Useable like SYSLOGF("format string", args...) similar to printf. Can be a macro or C function. Prints to serial monitor, likely using Serial.printf("format string", args) If SD card is connected (sd_started, etc.), a file should be created on startup on the SD card with the filename being the LOG_YEAR-MONTH-DAY-HOUR_MINUTE_SECOND in the format LOG_YYYY-MM-DD-HH_MM_SS for whenever the file is created. If this file was created on startup, SYSLOGF should also print to this file (treat it as a simple text file). If "%s" represents the string printed to serial monitor, the file output will have the following format: [YYYY-MM-DD_HH_MM_SS] "%s"

So doing SYSLOGF("Battery Voltage: %d\n", 80) at 05/16/2023 at 12:27:45 AM would print Battery Voltage: 80 to the serial monitor and if the SD card is accessible, print [2023-05-16_00_37_45] Battery Voltage: 80 to the file created on startup which has a name of LOG_2023-05-16_00_37_45 or similar