Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 1 month ago.
List up files (and directories) at the mbed LPC1768?
Hi, does anybody know how to list up files, which are on the flash of the mbed LPC1768? I do not know the file names, and I do not want to start a brute force. So is there any other possibility to list up files and directories from the mbed, or can I just list up files from an SD-card/USB-drive?
Hope for your answers, Frosch
3 Answers
11 years, 1 month ago.
Here is a code example for the SD card that reads the directory and sends it to the PC:
http://mbed.org/users/4180_1/notebook/reading-the-directory-on-an-sd-card/
The same code will work for the local file system with 8.3 filenames, but remember to change "/sd/myDir" to "/local" first
and add "LocalFileSystem local("local");" at the start of the source code.
11 years, 1 month ago.
Another good resource is the Handbook LocalFileSystem page, which lists some of the other constraints you may be faced with.
11 years, 1 month ago.
When I wanted to compile this code, it pushes out:
Error: Cannot open source input file "SDFileSystem.h": No such file or directory in "main.cpp", Line: 1, Col: 25
Can you please help me?
P.S. Thanks for your Answers :)
Frosch
Hey,
I compiled the program an ran it on the mbed. I opened HyperTerminal and opened my mbed connection.
There was no activity. Nothing....
I have this Code:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
- include "mbed.h"
- include <string>
- include <vector>
DigitalOut myled (LED1);
vector<string> filenames; filenames are stored in a vector string
void read_file_names(char *dir) { DIR *dp; struct dirent *dirp; dp = opendir(dir); read all directory and file names in current directory into filename vector while((dirp = readdir(dp)) != NULL) { filenames.push_back(string(dirp->d_name)); } closedir(dp); }
int main() { printf("Kannst du das Lesen?"); while(1) { read file names into vector of strings read_file_names("local/Textdateien"); print filename strings from vector using an iterator for(vector<string>::iterator it=filenames.begin(); it < filenames.end(); it++) { printf("%s\n\r",(*it).c_str()); myled = 1; wait(1); myled = 0; } } }
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
Does anybody know where to search or how to fix the problem?
Thanks for your reply
posted by 02 Nov 2013Did you add code for a filesystem driver to create the filesystem? - will need one to read the directory//
LocalFileSystem local("local"); //
https://mbed.org/handbook/LocalFileSystem is the one needed for the local flash flile system.
posted by 14 Nov 2013