8 years, 8 months ago.

How to write in a file with nucleo F401RE

I'm trying to write in a file but the file can't be read even if I create it before :

  1. include "mbed.h"
  2. include <stdlib.h>
  3. include <stdio.h>
  1. define TEST "test.txt"

Serial pc(SERIAL_TX, SERIAL_RX);

int main(){

FILE* fichier; if ((fichier = fopen(TEST,"w")) == NULL) Creation d'un fichier. Si apres sa création on arrive pa sà l'ouvrir alors le programme s'arrete { fprintf(stderr, "\nErreur: Impossible de lire le fichier %s\n",TEST); return(EXIT_FAILURE); }

fclose(fichier);

}

Question relating to:

2 Answers

5 years, 9 months ago.

@Rozenn, understand this reply is 3 years late but just went through a similar exercise today in an attempt to use this LocalFileSystem with W7500 board and had the same fault.

Issue is that this support for LocalFileSystem is limited to only 2 mbed boards (your Nucleo is not on that list):

https://os.mbed.com/questions/2735/LocalFileSystem-undefined/

8 years, 8 months ago.

You need to declare and open the filesystem object first. What type of file do you want to open? https://developer.mbed.org/handbook/LocalFileSystem https://developer.mbed.org/handbook/SDFileSystem

Something else?

I obtain data from a sensor and I would like to write in a file to use it. I would like to open a texte file. I will try with filesystem object. Thanks for your help.

posted by Rozenn Tassé 28 Jul 2015

I have try but when I declare : LocalFileSystem local("local"); I obtain this error : Error: Identifier "LocalFileSystem" is undefined in "main.cpp", Line: 26, Col: 2 I can't access to localFileSystem.h to check if it's well decalre.

posted by Rozenn Tassé 28 Jul 2015