Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Save_USB.cpp
00001 #include "mbed.h" 00002 #include "USBHostMSD.h" 00003 00004 Serial pc(USBTX,USBRX) ; 00005 00006 void Sauve_USB(float *tab,int taille) 00007 { 00008 USBHostMSD msd("usb"); 00009 00010 pc.printf("Connectez la clef USB sur le connecteur prevu a cet effet\n"); // Waiting for USB connection 00011 while(!msd.connect()) // try to connect a MSD device 00012 { 00013 } 00014 pc.printf("Clef USB connectee ne pas debrancher\n"); 00015 pc.printf("Ecriture des donnees sur la clef USB dans le fichier data.txt\n"); 00016 FILE *fp = fopen("/usb/data.txt","w"); 00017 if (fp != NULL) 00018 { 00019 // Ecriture en format texte éditable sous Notepad 00020 /* for (int i = 0 ; i < taille; i++) 00021 fprintf(fp,"%f\n", tab[i]); 00022 fclose(fp); */ 00023 00024 // Ecriture en binaire pour lecture avec Octave ou Matlab 00025 fwrite(tab,sizeof(tab[0]),taille,fp); 00026 fclose(fp); 00027 pc.printf("Ecriture terminee, vous pouvez debrancher la clef USB\n"); 00028 } 00029 else 00030 pc.printf("Impossible d'ouvrir le fichier data.txt\n"); 00031 }
Generated on Fri Feb 17 2023 21:41:46 by
