ladansedesdamnes
Active member
I'm creating a data logger sketch using SD card. The teensy receives the log name via external message, checks if that file exists and, if so, increments it with a suffix ("_X"). That part is working fine.
Whenever I try to actually create the files (not even writing data to them yet) I start getting erratic behavior. Specifically, here's what happened:
Sketch was able to create "original_name" file without issue. Then checks, file exists, increments and creates "original_name_1" without issue. Now when it tries to create "original_name_2", that fails. Restart teensy, fails again. Remove SD card from slot, open in reader, check for files (all created ok), delete all, re-insert into teensy.
"original_name", ""original_name_1" and "original_name_2" all created successfully. Now fails on "original_name_3".
Edit the sketch change to other log name, now fails on creating "original_name" base file. Changing again sometimes fails at base name, sometimes writes some iterations, but never managed to get past the third increment.
I'm stumped.
Code is as simple as can be.
Using
#include <SD.h>
#include <SPI.h>
Other info:
I'm using the onboard SD card slot (obviously), an OctoWS2811 Adaptor and a common anode RGB led connected to pins 24, 28, and 37 (free PWM pins). Using Visual Micro on Visual Studio.
32GB SD card formatted using official SD Memory Card Formatter, and shows no errors when checked.
Whenever I try to actually create the files (not even writing data to them yet) I start getting erratic behavior. Specifically, here's what happened:
Sketch was able to create "original_name" file without issue. Then checks, file exists, increments and creates "original_name_1" without issue. Now when it tries to create "original_name_2", that fails. Restart teensy, fails again. Remove SD card from slot, open in reader, check for files (all created ok), delete all, re-insert into teensy.
"original_name", ""original_name_1" and "original_name_2" all created successfully. Now fails on "original_name_3".
Edit the sketch change to other log name, now fails on creating "original_name" base file. Changing again sometimes fails at base name, sometimes writes some iterations, but never managed to get past the third increment.
I'm stumped.
Code is as simple as can be.
Code:
File log_file = SD.open(log_name, FILE_WRITE);
if (!log_file) {
Serial.println("File open failed!");
}
if(log_file) log_file.close();
Using
#include <SD.h>
#include <SPI.h>
Other info:
I'm using the onboard SD card slot (obviously), an OctoWS2811 Adaptor and a common anode RGB led connected to pins 24, 28, and 37 (free PWM pins). Using Visual Micro on Visual Studio.
32GB SD card formatted using official SD Memory Card Formatter, and shows no errors when checked.
Last edited: