Try to fix the sd card issue, but there's no change :-/

For some crazy reason it's not writing to the cd card anymore. At all. 
Arghhhh!
This commit is contained in:
Starbeamrainbowlabs 2019-07-09 13:12:32 +01:00
parent 7dba01bff1
commit b95505eaff
3 changed files with 15 additions and 15 deletions

View File

@ -69,10 +69,10 @@
#define PIN_SPI_CS_SD 3
// The filename on the microSD card to store data in.
#define SD_FILENAME F("data.tsv")
#define SD_FILENAME F("DATA.TSV")
// Whether to write debug information to the filename below. This could compromise privacy, so it should be commented out for production.
// #define SD_DEBUG_ENABLED
// The filename on the microSD card to store debug information in
#define SD_FILENAME_DEBUG F("debug.log")
#define SD_FILENAME_DEBUG F("DEBUG.LOG")

View File

@ -8,18 +8,13 @@
// FUTURE: We might be able to trim it down if we disable long filenames with #define
SdFat store_init() {
SdFat card;
if(!card.begin(PIN_SPI_CS_SD)) {
Serial.println("Error: MicroSD card init failed");
while(true) delay(100);
}
return card;
}
void store_reading(uint32_t id, GPSLocation location) {
// Port the rest of this to SdFat from SD
SdFat card = store_init();
SdFat card;
if(!card.begin(PIN_SPI_CS_SD)) {
Serial.println(F("Error: MicroSD card init failed"));
while(true) delay(100);
}
// Open the file to write the data to. If it doesn't exist it will be created.
// Unlike elsewhere, FILE_WRITE opens the file with the cursor starting at the end, so it's basically actually equivalent to FILE_APPEND that we use in other environments. Confusing, I know.
@ -28,11 +23,16 @@ void store_reading(uint32_t id, GPSLocation location) {
handle.printField(id, '\t');
handle.printField(location.lat, '\t', places);
handle.printField(location.lng, '\n', places);
handle.sync();
handle.close(); // Syncs implicitly
}
/*
void store_debug(char* buffer, int size) {
SdFat card = store_init();
SdFat card;
if(!card.begin(PIN_SPI_CS_SD)) {
Serial.println("Error: MicroSD card init failed");
while(true) delay(100);
}
File handle = card.open(SD_FILENAME_DEBUG, O_APPEND | O_CREAT | O_WRONLY);
handle.write(buffer, size);
handle.write('\n');

View File

@ -8,7 +8,7 @@
/**
* Initialise the microSD card storage subsystem.
*/
void store_init();
// void store_init();
/**
* Store a measurement on the microSD card.
* @param id The unique random id of the reading.