A simple serial test program for the re-written SDFileSystem library.

Dependencies:   SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
neilt6
Date:
Mon Aug 18 15:11:09 2014 +0000
Parent:
11:2be49b81dc0b
Child:
13:c6552456454f
Commit message:
Updated SDFileSystem library and improved error handling

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SDFileSystem.lib	Fri Aug 15 17:55:35 2014 +0000
+++ b/SDFileSystem.lib	Mon Aug 18 15:11:09 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/neilt6/code/SDFileSystem/#eebddab6eff2
+http://mbed.org/users/neilt6/code/SDFileSystem/#635147efa748
--- a/main.cpp	Fri Aug 15 17:55:35 2014 +0000
+++ b/main.cpp	Mon Aug 18 15:11:09 2014 +0000
@@ -39,16 +39,18 @@
     FileHandle* file = sd.open("Test File.bin", O_RDONLY);
     if (file != NULL) {
         timer.start();
-        while (file->read(buffer, sizeof(buffer)) == sizeof(buffer));
+        int iterations = 0;
+        while (file->read(buffer, sizeof(buffer)) == sizeof(buffer))
+            iterations++;
         timer.stop();
-        if (file->close())
+        if (iterations != (1048576 / sizeof(buffer)))
+            printf("read error!\n");
+        else if (file->close())
             printf("failed to close file!\n");
-        else {
-            if (sd.remove("Test File.bin"))
-                printf("failed to delete file!\n");
-            else
-                printf("done!\n\tResult: %.2fKB/s\n", 1024 / (timer.read_us() / 1000000.0));
-        }
+        else if (sd.remove("Test File.bin"))
+            printf("failed to delete file!\n");
+        else
+            printf("done!\n\tResult: %.2fKB/s\n", 1024 / (timer.read_us() / 1000000.0));
         timer.reset();
     } else {
         printf("failed to open file!\n");
@@ -57,9 +59,10 @@
 
 int main()
 {
-    //Configure CRC and large frames
+    //Configure CRC, large frames, and write validation
     sd.crc(true);
     sd.large_frames(true);
+    sd.write_validation(true);
 
     //Fill the buffer with random data for the write test
     srand(time(NULL));