123
Dependencies: SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
Revision 2:a78724db47d9, committed 2017-07-12
- Comitter:
- qwer7ttw
- Date:
- Wed Jul 12 05:19:37 2017 +0000
- Parent:
- 1:e4d7342be507
- Commit message:
- 123
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 Tue May 16 05:18:55 2017 +0000 +++ b/SDFileSystem.lib Wed Jul 12 05:19:37 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec +https://developer.mbed.org/users/qwer7ttw/code/SDFileSystem/#61a6ff0cf29c
--- a/main.cpp Tue May 16 05:18:55 2017 +0000 +++ b/main.cpp Wed Jul 12 05:19:37 2017 +0000 @@ -1,19 +1,44 @@ #include "mbed.h" #include "SDFileSystem.h" - -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board - + Serial pc(SERIAL_TX, SERIAL_RX); + +SDFileSystem sd(PC_12, PC_11, PC_10, D15, "sd"); // the pinout on the mbed Cool Components workshop board +//LocalFileSystem local("local"); int main() { - printf("Hello World!\n"); - + int i; + //pc.printf("Hello World!\n"); + char Buffer[8192],Buffer1[8192]; mkdir("/sd/mydir", 0777); - + //FILE *fb = fopen("/local/out.txt", "w"); FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); - if(fp == NULL) { + FILE *fq = fopen("/sd/mydir/sdtest1.txt", "w"); + if(fp == NULL ||fp == NULL ) { error("Could not open file for write\n"); } - fprintf(fp, "Hello fun SD Card World!"); + else{ + //fprintf(fp, "hello world"); + for(i=0;i<=10;i++) + {fprintf(fp, "%d ",i); + fprintf(fq, "%d ",i+10);} + //pc.printf("sucess!!!!!!!!\n"); fclose(fp); - - printf("Goodbye World!\n"); + fclose(fq); + + } + FILE *fa = fopen("/sd/mydir/sdtest.txt", "r"); + FILE *fb = fopen("/sd/mydir/sdtest1.txt", "r"); + if(fa == NULL||fb == NULL) { + error("Could not open file for read\n"); + } + else{ + fgets (Buffer, 8192, fa); + fgets (Buffer1, 8192, fb); + pc.printf("%s\n",Buffer); + pc.printf("%s\n",Buffer1); + fclose(fa); + fclose(fb); + } + +// if(c=='5') +// pc.printf("%s",Buffer); }