Hi, im having a trouble with printf function. Each printf() doesnt work beside the first one. Does any one know why it wont work ?
My output in terminal for the first run (when the config.cfg does not exist) is only :
"Config not found!"
and should be :
"Config not found!
File Saved
File Saved 2"
Fprintf() work correctly the file is created and text added.
Here's my code:
#include "mbed.h"
#include "SDFileSystem.h"
#include <stdio.h>
#include <string.h>
#include <iostream>
Serial pc(USBTX, USBRX); // tx, rx
LocalFileSystem local("local");
SDFileSystem sd(p5, p6, p7, p8, "sd");
DigitalOut PowerLed(LED1);
DigitalOut txLed(LED2);
Ticker timeout1;
Ticker secInterval;
Timeout ledDelay;
time_t seconds; /// = time(NULL);
int main() {
FILE *pFile = fopen("/sd/config.cfg", "r");
if (pFile == NULL) {
printf("Config not found!\n");
pFile = fopen("/sd/config.cfg", "a");
}
if (pFile == NULL) {
printf("Config 2 not found");
} else {
fprintf(pFile, "Hello World !\n");
fprintf(pFile, "Hello World 2!\n");
//wait(0.5);
printf("File Saved");
}
fclose(pFile);
printf("File Saved 2");
}
Hi, im having a trouble with printf function. Each printf() doesnt work beside the first one. Does any one know why it wont work ?
My output in terminal for the first run (when the config.cfg does not exist) is only :
"Config not found!"
and should be :
"Config not found!
File Saved
File Saved 2"
Fprintf() work correctly the file is created and text added.
Here's my code: