mirror of
https://gitlab.com/lander-team/lander-cpp.git
synced 2025-06-16 15:17:23 +00:00
Merge branch '28-increment-file-name-on-sd-card' into 'main'
Resolve "Increment File Name on SD Card" Closes #28 See merge request lander-team/lander-cpp!21
This commit is contained in:
commit
fe1a5b9bc0
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -45,7 +45,8 @@
|
|||||||
"string": "cpp",
|
"string": "cpp",
|
||||||
"chrono": "cpp",
|
"chrono": "cpp",
|
||||||
"ratio": "cpp",
|
"ratio": "cpp",
|
||||||
"thread": "cpp"
|
"thread": "cpp",
|
||||||
|
"string_view": "cpp"
|
||||||
},
|
},
|
||||||
"C_Cpp.clang_format_fallbackStyle": "LLVM",
|
"C_Cpp.clang_format_fallbackStyle": "LLVM",
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
@ -35,11 +34,33 @@ void initFile() {
|
|||||||
}
|
}
|
||||||
Serial.println("Card initialized.");
|
Serial.println("Card initialized.");
|
||||||
|
|
||||||
// Delete any previous existing files
|
int i = 1;
|
||||||
if (SD.exists("simOut.csv")) {
|
Serial.print("simOut_" + String(i) + ".csv");
|
||||||
SD.remove("simOut.csv");
|
const char *fileName;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (SD.exists("simOut.csv")) {
|
||||||
|
while (i > 0) {
|
||||||
|
fileName = ("simOut_" + String(i) + ".csv").c_str();
|
||||||
|
|
||||||
|
if (!SD.exists(fileName)) {
|
||||||
|
// Open simOut_i.csv
|
||||||
|
dataFile = SD.open(fileName, FILE_WRITE);
|
||||||
|
|
||||||
|
if (dataFile) {
|
||||||
|
Serial.println("File successfully opened!");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// if the file didn't open, print an error:
|
||||||
|
Serial.println("Error opening output file. \n\nABORTING SIMULATION");
|
||||||
|
teensyAbort();
|
||||||
|
}
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Open simOut.csv
|
// Open simOut.csv
|
||||||
dataFile = SD.open("simOut.csv", FILE_WRITE);
|
dataFile = SD.open("simOut.csv", FILE_WRITE);
|
||||||
if (dataFile) {
|
if (dataFile) {
|
||||||
@ -47,9 +68,10 @@ void initFile() {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if the file didn't open, print an error:
|
// if the file didn't open, print an error:
|
||||||
Serial.println("Error opening simOut.csv. \n\nABORTING SIMULATION");
|
Serial.println("Error opening output file. \n\nABORTING SIMULATION");
|
||||||
teensyAbort();
|
teensyAbort();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// File Header
|
// File Header
|
||||||
dataFile.println(
|
dataFile.println(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user