Can I make a file directly on mbed(drive F: on my PC) via fopen?

02 Jul 2010

Hello!

I tried to make a file(like abc.txt) on mbed which works as the drive F: on my PC(Windows).

Is this an unsupported way of making a file around mbed?

Or, are there any errors in my code (to make a file directly on my mbed)?

I hope someone to let me know how to do it!

Thanks a lot, in advence, for any help!

----------

my trial code is: (these lines are borrowed from a sample making a file on SD Cards)

    FILE *fp = fopen("\abc.txt", "w+");
    if(fp == NULL) {
        error("Could not open file for write\n\r");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp);

 

 

 

02 Jul 2010

Hi marutsu

Try the following:

LocalFileSystem local("local");

FILE *fp = fopen("/local/abc.txt", "w+");

fprintf(fp, "Hello fun SD Card World!");

fclose(fp);

Good luck!

02 Jul 2010

Hi Alex,

Thank you for your help.

But, I failed in making a text file directly on my mbed(F: drive in a Windows PC).

In my code, fopen succeeded! fprintf didn't succeed, and an error message box appeared as like cited below;It reads (translation in Englisg from Japanese),

Message title: Windows - Data loss in delayed writing

Error Message: A part of data for a file \Device\Harddisk1\DP(1)0-0+6\ failed in being stored. Data loss occurred. This error may be happened by Computer Hardware errors or Network connection errors. This file should be saved elsewhere, in a different location.

I've confirmed that the firmware version is 16457.

I will try more following samples in Handbook explaining LocalFileSystem interface. Thank you for your help! I need some more suggestions!

marutsu

 

 

 

 

 

06 Jul 2010

Hello,

Simply I could succeed in making a text file directly on mbed module(Drive F: on Windows).

I tried some more times of similar example programs.

Sometimes, I succeeded, and other times, I failed. But, basically I am now assured that text files could be made directly on a mbed module by simple source codes to do so! 

Thank you any given advices!