8000 Finalize and add SD device test · Issue #5403 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content
Finalize and add SD device test #5403
Open
@devyte

Description

@devyte

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • I have filled out all fields below.

Platform

  • Hardware: All
  • Core Version: latest git
  • Development Env: All
  • Operating System: All

Problem Description

From #4444 : Sketch below to test SD on device.
Possibly add to devices test, similar to @d-a-v 's interactive WiFi test sketch, maybe add more actions.

MCVE Sketch

Steps:

Send m to mount
Send u and y to unmount
Send m to mount again, if SD.end() is commented, you are in a endless "SD initialization failed!" loop.

File myFile;
bool mounted = false;

void setup() {
    Serial.begin(115200);
}

void loop() {
    if (mounted && Serial.peek() == 'u') {
        Serial.read();
        Serial.println("Unmount SD and press 'y' to continue");
        while (Serial.peek() != 'y') {
            delay(1000);
        }
        mounted = false;
        Serial.println("SD unmounted.");
        Serial.read();
    } else if (!mounted && Serial.peek() == 'm') {
        Serial.read();

        //Uncomment this to finish while (!SD.begin(D2)) endless loop
        //SD.end();

        while (!SD.begin(D2)) {
            Serial.println("SD initialization failed!");
            delay(1000);
        }
        mounted = true;
        Serial.println("Initialization succeded!");
    }

    if (mounted) {
        myFile = SD.open("test.txt");
        Serial.println("Printing test.txt contents:");
        while (myFile.available()) {
            Serial.write(myFile.read());
        }
        myFile.close();
        Serial.println();
        Serial.println("All contents of test.txt printed!");

        Serial.println("SD mounted, press 'u' to unmount");
    } else {
        Serial.println("SD unmounted, press 'm' to mount");

    }

    Serial.println("Wait 3 seconds...");
    delay(3000);
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0