4180Lab2Part9 file IO and output to term

Dependencies:   SDFileSystem mbed

Fork of SDFileSystem_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
CRaslawski
Date:
Mon Feb 27 22:52:35 2017 +0000
Parent:
0:bdbd3d6fc5d5
Commit message:
initial commit

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
diff -r bdbd3d6fc5d5 -r e8f7210820fa SDFileSystem.lib
--- a/SDFileSystem.lib	Fri Dec 07 11:25:01 2012 +0000
+++ b/SDFileSystem.lib	Mon Feb 27 22:52:35 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
+https://developer.mbed.org/users/CRaslawski/code/SDFileSystem/#972418299e2f
diff -r bdbd3d6fc5d5 -r e8f7210820fa main.cpp
--- a/main.cpp	Fri Dec 07 11:25:01 2012 +0000
+++ b/main.cpp	Mon Feb 27 22:52:35 2017 +0000
@@ -1,8 +1,12 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
+#include <stdio.h>
  
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
- 
+SDFileSystem sd(p11, p12, p13, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+char myline[100];
+
+//define MAXLINE 100 char myline [MAXLINE];/* int i, inch;*/ 
+
 int main() {
     printf("Hello World!\n");   
  
@@ -12,8 +16,28 @@
     if(fp == NULL) {
         error("Could not open file for write\n");
     }
-    fprintf(fp, "Hello fun SD Card World!");
+    fprintf(fp, "Hello SD file World!");
     fclose(fp); 
  
     printf("Goodbye World!\n");
+    
+    FILE *fp2 = fopen("/sd/mydir/sdtest.txt", "r");
+    if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
+    //fgets(fp2,"%s",myline);
+    else {
+        if(fgets(myline,100,fp2)!=NULL)
+        {
+            printf("Opened file for read.\n");
+            printf("\n\rRead from SD card file:\"%s\"",myline);
+            puts(myline);
+        }
+    }
+    fclose(fp2);
+    printf("stuff");
+    
+    //printf("Opened file for read.\n");
+    //printf("\n\rRead from SD card file:\"%s\"",myline);
+    //fclose(fp2);
 }