hello
i have sketch using sd.h , serialcommand.h pass commands on serial create , write files (commands in sketch called csd, lsd, dsd). this works fine.
i added command list files on sd card (sd). this gets bit weird.
i can create, read , write files day long, if open root "/" doesn't return files - , read/write fails.
however, if open "/" after booting works fine. until create/read , write files - "/" won't open more. thought due not closing "/" - think closing correctly.
any ideas? doing wrong?
code snippets: i've tried 2 methods list root directory structure:
//first method read dir
if (!card.init(spi_half_speed, 10)) {
serial.println("initialization failed. things check:");
serial.println("* card inserted?");
serial.println("* wiring correct?");
serial.println("* did change chipselect pin match shield or module?");
return;
} else {
serial.println("wiring correct , card present.");
}
if (!volume.init(card)) {
serial.println("could not find fat16/fat32 partition.\n\rmake sure you've formatted card");
}
root.openroot(volume);
root.ls(ls_r | ls_date | ls_size);
root.close();
and
//second method read dir
myfile = sd.open("/");
if(myfile) {
printdirectory(myfile, 0);
serial.println("done!");
}
myfile.close();
return;
both give pretty same response.
any ideas?
i have sketch using sd.h , serialcommand.h pass commands on serial create , write files (commands in sketch called csd, lsd, dsd). this works fine.
i added command list files on sd card (sd). this gets bit weird.
i can create, read , write files day long, if open root "/" doesn't return files - , read/write fails.
however, if open "/" after booting works fine. until create/read , write files - "/" won't open more. thought due not closing "/" - think closing correctly.
any ideas? doing wrong?
code snippets: i've tried 2 methods list root directory structure:
//first method read dir
if (!card.init(spi_half_speed, 10)) {
serial.println("initialization failed. things check:");
serial.println("* card inserted?");
serial.println("* wiring correct?");
serial.println("* did change chipselect pin match shield or module?");
return;
} else {
serial.println("wiring correct , card present.");
}
if (!volume.init(card)) {
serial.println("could not find fat16/fat32 partition.\n\rmake sure you've formatted card");
}
root.openroot(volume);
root.ls(ls_r | ls_date | ls_size);
root.close();
and
//second method read dir
myfile = sd.open("/");
if(myfile) {
printdirectory(myfile, 0);
serial.println("done!");
}
myfile.close();
return;
both give pretty same response.
any ideas?
Arduino Forum > Using Arduino > Storage > SD.h Nano - can't read/write after directory listing (or vv)
arduino
Comments
Post a Comment