SD.open file question/problem
i have sketch monitors , logs multiple sensors. works if logs 1 log file. want log each sensor it's own log file. have function assembles sensor values , time stamp, writes sd card. compile error when try use variable in sd.open statement. not sure i'm missing, or other method should use.
here error get:
time_and_sensor_log.ino: in function 'void logit(long int, string, int, string)':
time_and_sensor_log:105: error: no matching function call 'sdclass::open(string&, int)'
c:\program files (x86)\arduino\libraries\sd\src/sd.h:73: note: candidates are: file sdclass::open(const char*, uint8_t)
here 2 samples of code open , write portions of function.
here error get:
time_and_sensor_log.ino: in function 'void logit(long int, string, int, string)':
time_and_sensor_log:105: error: no matching function call 'sdclass::open(string&, int)'
c:\program files (x86)\arduino\libraries\sd\src/sd.h:73: note: candidates are: file sdclass::open(const char*, uint8_t)
here 2 samples of code open , write portions of function.
code: [select]
/* sample 1 works */
serial.println("opening log file"); // print msg. know got here.
file datafile = sd.open("sensor4.txt", file_write);
datafile.println(datastring); // write assembled data information
datafile.close();
serial.println(datastring); // print diag.
/* sample two causes error*/
string filename = "sensor4.txt";
serial.println("opening log file"); // print msg. know got here.
file datafile = sd.open(filename, file_write);
datafile.println(datastring); // write assembled data information
datafile.close();
serial.println(datastring); // print diag.
quote
i compile error when try use variable in sd.open statement.
no. error when try use wrong type of variable in sd.open statement.
do favor. forget stupid string class exists. use char arrays.
code: [select]
char *filename = "sensor4.txt";
serial.println("opening log file"); // print msg. know got here.
file datafile = sd.open(filename, file_write);
Arduino Forum > Using Arduino > Programming Questions > SD.open file question/problem
arduino
Comments
Post a Comment