11 years 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 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.

Accepted Answer

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

posted by Julian Lorenz 31 Oct 2013
11 years ago.

Another good resource is the Handbook LocalFileSystem page, which lists some of the other constraints you may be faced with.

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

posted by Julian Lorenz 31 Oct 2013
11 years 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

If you are using only the localfilesystem you can delete that include line

posted by jim hamblen 31 Oct 2013

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: #################

  1. include "mbed.h"
  2. include <string>
  3. 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 Julian Lorenz 02 Nov 2013

Did 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 jim hamblen 14 Nov 2013