Skip to content

SD_MMC.flush() don't flush pending data to the file #1173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
magnuskarlsson opened this issue Mar 4, 2018 · 2 comments
Closed

SD_MMC.flush() don't flush pending data to the file #1173

magnuskarlsson opened this issue Mar 4, 2018 · 2 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@magnuskarlsson
Copy link

Hardware:

Board: ESP Wroom-32

Description:

SD_MMC.flush() do not sync the file as expected. Without SD_MMC.close() the file is empty.

Sketch:

#include "FS.h"
#include "SD_MMC.h"

File file;

void setup(){
    Serial.begin(115200);
    if(!SD_MMC.begin()){
        Serial.println("Card Mount Failed");
        return;
    }
    uint8_t cardType = SD_MMC.cardType();

    if(cardType == CARD_NONE){
        Serial.println("No SD_MMC card attached");
        return;
    }

    Serial.print("SD_MMC Card Type: ");
    if(cardType == CARD_MMC){
        Serial.println("MMC");
    } else if(cardType == CARD_SD){
        Serial.println("SDSC");
    } else if(cardType == CARD_SDHC){
        Serial.println("SDHC");
    } else {
        Serial.println("UNKNOWN");
    }

    uint64_t cardSize = SD_MMC.cardSize() / (1024 * 1024);
    Serial.printf("SD_MMC Card Size: %lluMB\r\n", cardSize);

    file = SD_MMC.open("/hello.txt", FILE_WRITE);
    if(!file){
        Serial.println("Failed to open file for writing");
        return;
    }
    if(file.print("Hello ***\r\n")){
        Serial.println("File written");
    } else {
        Serial.println("Write failed");
    }
    file.flush();

    // file.close();
}

void loop(){

}

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here 
@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

1 participant