Commit 8b3997b0 authored by Eric Duminil's avatar Eric Duminil
Browse files

show_csv command

parent 34cf4989
#include "csv_writer.h" #include "csv_writer.h"
//TODO: Allow CSV download via USB Serial, when requested (e.g. via a Python script)
namespace config { namespace config {
// Values should be defined in config.h // Values should be defined in config.h
uint16_t csv_interval = CSV_INTERVAL; // [s] uint16_t csv_interval = CSV_INTERVAL; // [s]
...@@ -119,6 +117,7 @@ namespace csv_writer { ...@@ -119,6 +117,7 @@ namespace csv_writer {
sensor_commands::defineIntCallback("csv", setCSVinterval, " 60 (Sets CSV writing interval, in s)"); sensor_commands::defineIntCallback("csv", setCSVinterval, " 60 (Sets CSV writing interval, in s)");
sensor_commands::defineCallback("format_filesystem", formatFilesystem, " (Deletes the whole filesystem)"); sensor_commands::defineCallback("format_filesystem", formatFilesystem, " (Deletes the whole filesystem)");
sensor_commands::defineCallback("show_csv", showCSVContent, " (Displays the complete CSV file on Serial)");
} }
File openOrCreate() { File openOrCreate() {
...@@ -176,6 +175,21 @@ namespace csv_writer { ...@@ -176,6 +175,21 @@ namespace csv_writer {
led_effects::showKITTWheel(color::green, 1); led_effects::showKITTWheel(color::green, 1);
} }
void showCSVContent() {
Serial.print(F("### "));
Serial.print(filename);
Serial.println(F(" ###"));
File csv_file;
if (FS_LIB.exists(filename)) {
csv_file = FS_LIB.open(filename, "r");
while (csv_file.available()) {
Serial.write(csv_file.read());
}
csv_file.close();
}
Serial.println(F("################"));
}
void formatFilesystem() { void formatFilesystem() {
FS_LIB.format(); FS_LIB.format();
led_effects::showKITTWheel(color::blue, 2); led_effects::showKITTWheel(color::blue, 2);
......
...@@ -27,6 +27,7 @@ namespace csv_writer { ...@@ -27,6 +27,7 @@ namespace csv_writer {
extern const String filename; extern const String filename;
void setCSVinterval(int32_t csv_interval); void setCSVinterval(int32_t csv_interval);
void showCSVContent();
void formatFilesystem(); void formatFilesystem();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment