![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
dsfa
Dependencies: dsf SDFileSystem TextLCD mbed stepper_moter
Fork of my_example_Nucleo_Ex05_SD_zhangyuxiang2 by
Diff: SDRead/SDRead.cpp
- Revision:
- 4:c88bf297ee75
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDRead/SDRead.cpp Tue May 08 01:50:44 2018 +0000 @@ -0,0 +1,40 @@ +#include "SDRead.h" + +SDRead::SDRead(PinName mosi,PinName miso,PinName sclk,PinName cs,const char *name):SDFileSystem(mosi,miso,sclk,cs,name) +{} +bool SDRead:: Get_FileDir() +{ + this -> mount(); + DirHandle *dh = opendir("/sd/"); + if(!dh){ + return false; + } + dirent *entry; + for(;;) + { + entry = dh -> readdir(); + if(!entry) + {break;} + string dir_name = entry -> d_name; + if(dir_name == "System Volume Information") + continue; + File_dir.push_back(dir_name); + } + dh -> closedir(); + return true; +} +bool SDRead::Read_File(const char* FileName) +{ + FILE *fp1 = fopen(FileName,"r"); + if(fp1 == NULL) + { + return false; + } + char buf[200]; + while(fgets(buf,sizeof(buf),fp1) != NULL) + { + string info = buf; + Info.push_back(info); + } + return true; +} \ No newline at end of file