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.
10 years, 11 months ago.
LocalFileSystem
Hi,
i know there are many many posts on localfilesystem problems and how tos, but i did not find an answer...
system: mbed lpc1768
my problem: i wanted to read a file from the mbed space that shows up when connected via usb (where the .bin goes ant the mbed.htm is).
following code ends in error:
LocalFileSystem local("local");
printf("File Parsing:\r\n");
FILE *fp2 = fopen( "/local/registers.txt", "r");
printf("Loading file:\r\n");
if ( fp2 == NULL ) {
error("Could not open file for read operation.\r\n");
}
so i tried to start at the beginning and implemented the example from the localfilesystem: localfilesystem example copied to compiler:
#include "mbed.h"
LocalFileSystem local("local"); // Create the local filesystem under the name "local"
int main() {
FILE *fp = fopen("/local/out.txt", "w"); // Open "out.txt" on the local file system for writing
fprintf(fp, "Hello World!");
fclose(fp);
}
i am connected to the mbed via usb, i see the device and the bin but the out.txt never shows up.
i also tried another example:
LocalFileSystem local("local");
FILE *fp = fopen("/local/test.txt", "w");
fprintf(fp, "Hello file system!\n");
if ( fp == NULL ) {
error("Could not open file for write operation.\r\n");
}
fclose(fp);
which throwed no error but showed no file. after some restarts and refreshes i saw test.txt and TEST.TXT but neither file was accessibl. windows throwed an access error message. When i deleted it and loaded blinky demo with only led blinking the files always reappeared.
i flashed the newest firmware again to the mbed and now the files are gone but i still cannot read or write to files.
what am i missing?
1 Answer
10 years, 11 months ago.
Hi Jörn,
You are using long file name for reading file. It could be fine if you use "8.3" format file name. The name should be 8 characters or less and suffix should be 3 chars or less
If you try "registrs.txt" instead of "registers.txt", it will be fine ;)