Hi Syadav2. In that example i focused to text manipulate. I added a new function readRaw(), so instead using char array buffer, use a byte array and this function. e.g.
byte adatBuffer[255];
flashDrive.setFileName("OHM.PNG");
flashDrive.openFile();
//read data from flash drive until we reach EOF
while(!flashDrive.getEOF()){
flashDrive.readRaw(adatBuffer, sizeof(adatBuffer));
for(int f = 0; f < sizeof(adatBuffer); f++){ // here i print the raw image data to the serial port
Serial.write(adatBuffer[f]);
}
}
flashDrive.closeFile();
case 51: //3
printInfo("COMMAND3: Read File: OHM.PNG"); // Read the contents of this file on the USB disk, and display contents in the Serial Monitor
flashDrive.setFileName("OHM.PNG"); //set the file name
flashDrive.openFile(); //open the file
while (!flashDrive.getEOF()) {
flashDrive.readRaw(adatBuffer, sizeof(adatBuffer));
for (int f = 0; f < sizeof(adatBuffer); f++) { // here i print the raw image data to the serial port
Serial.write(adatBuffer[f]);
}
}
flashDrive.closeFile(); //at the end, close the file
printInfo("Done!");
break;
Thank you for your feedback. Meanwhile i found an error, the return value of these functions is a boolean value that gives information if there is no more readable data (End Of File). That was good when i focused just to read-write NULL terminated strings. But with the readRaw function, we really have no information when reach the EOF, whether our buffer is completely loaded with data or just e.g. 10 byte is a valid data the rest are old. I need to change these functions to return byte with the count of totally read out bytes number. But that can make trouble for those users who already use this lib in their code. Or intermediate solution is to write a new function which one return the read out bytes number, but the former seems to me better and more logical.