Hello,
In this code I need to pass file to the function and then read it inside the function.
The problem I can not read anything. it print "Opening file to read failed"
I am using ESP32 CAM
#include "SD_MMC.h"
void printpassf(File &f){
File file2 = SD_MMC.open("/f.txt", FILE_READ);
if (!file2) {
Serial.println("Opening file to read failed");
return;
}
Serial.println("File Content:");
while (file2.available()) {
Serial.write(file2.read());
}
}
void setup() {
Serial.begin(115200);
if (!SD_MMC.begin()) {
Serial.println("Failed to mount card");
return;
}
File file = SD_MMC.open("/test.txt", FILE_WRITE);
if (!file) {
Serial.println("Opening file to write failed");
return;
}
if (file.print("Test file write")) {
Serial.println("File write success");
} else {
Serial.println("File write failed");
}
printpassf(file);
file.close();
}
void loop() {}