#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <assert.h>
#include <fileapi.h>
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "semphr.h"
#include "FreeRTOSConfig.h"
/* File IO Headers*/
#include "fat_sl.h"
FILE *filepointer;
void main (void)
{
filename = "........Log_1.txt";
filepointer = fopen(filename, "w+");
fputs(">> Start of the log file. nn", filepointer);
fclose(filepointer);
}
How to use file operations in Win32 demo file
Wanted to know how can we do read and write operations in a text file , while running FreeRTOS demo file in WIN32-MSVC section.
I tried using this earlier but it started giving me build errors. Tried using fat_sl.h file also but got build errors with that as well.
How to use file operations in Win32 demo file
“Build errors” is not helpful unless you say what they are, because all
I can do now is ask what they were, but it is also not clear what you
are wanting to do – use the FreeRTOS FAT file system to write to (for
example) a RAM disk, or use the windows file system to write a text file
to the disk of your host computer? If the former then there are some
Win32 examples in the labs download. If the latter then you will be
making Windows system call, which can’t really be called safely from
tasks under the control of the FreeRTOS scheduler as Windows can block
threads making system calls and the FreeRTOS scheduler assumes it is the
only thing that will block threads. That is why the TCP examples send
messages that are printed to the screen to a separate thread outside of
the control of FreeRTOS, so if they get blocked by Windows is doesn’t
effect the FreeRTOS program. That said, as long as you only write to
the disk from a single thread, I have found it works ok probably because
you are only really writing to the disk cache rather than the disk itself.