Hayley Cashdollar
/
LocalFileSystem_Read
read and write to local file system.
main.cpp
- Committer:
- cashdollar
- Date:
- 2015-06-30
- Revision:
- 0:60661ba12125
File content as of revision 0:60661ba12125:
#include "mbed.h" Serial pc(USBTX, USBRX); // tx, rx DigitalOut myled(LED1); float Right=1.123456; // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v ) float Left=1.123; // gemeten waarde bij 4mA ( 0..1 <> 0..3.3v ) char A[10], B[10]; LocalFileSystem local("local"); // Create the local filesystem under the name "local" //float leftOff; void ReadFile (void) { FILE *set = fopen("/local/calib.txt", "r"); // Open "setup.txt" on the local file system for read fscanf(set,"%s %f",A,&Left); // read offset fscanf(set,"%s %f",A,&Right); // read offset fclose(set); } void WriteFile(void) // write to USB memory { FILE *fp = fopen("/local/calib.txt", "w"); // Open "setup.txt" on the local file system for write fprintf(fp,"Left %f\r\n",Left); // read offset fprintf(fp,"Right %f\r\n",Right); // read offset //fprintf(fp,"gain %f\r\n",lOffset); // read gain fclose(fp); } int main() { pc.baud(912600); WriteFile(); wait(3); ReadFile();// when you run first time without this line, the setup file is on created wait(1); pc.printf("Left Offset is: %f, Right Offset is: %f\r\n", Left, Right); //pc.printf("%f\n roffset", roff); }