User`s manual

150 digi.com File Systems
To see what was written, use the “rd” command.
10.2.3.2 Non-Blocking Sample
To use the FAT file system in non-blocking mode, do not include the statement #define FAT_BLOCK
in your application. The program interface to the library is the same as the blocking version, with the
exception of the return code -EBUSY from many of the API functions.
The sample program Fat_NB_Costate.c in the Samples\FileSystem folder is an example of a
non-blocking application. To view the code in its entirety, open it in Dynamic C. The following discussion
will not examine every line of code, but will focus on what shows the non-blocking nature of the FAT
library and how the application takes advantage of it.
Run Fat_NB_Costate.c and after 10 seconds the Stdio window will show something similar to the fol-
lowing:
Figure 2. Screen Shot of Fat_NB_Costate.c Running
Each line is an entry into a file that is stored in the FAT file system. The file is appended once every second
and read and displayed once every ten seconds. In addition to the file system use and the screen output, if
you are using an RCM3300, RCM3700 or PowerCore FLEX development board, the application blinks
the LED on your board.
The code preceding main() brings in the required library and declares the file structure. And, as expected,
there is no #define for the macro FAT_BLOCK. At the start of main() some system variable are cre-
ated and initialized. This is followed by the code to bring up the FAT file system, which is similar to what
we examined in Section 10.2.2.1 when looking at fat_create.c, with two essential differences. One,
since we have initialized the FAT to be in non-blocking and we are making some calls to FAT functions
that must return before we can continue, we must wait for the return.
> rd rabbit.txt
rabbit.txt 1024 The quick brown fox jumps over the lazy dog
rabbit.txt 1024 The quick brown fox jumps over the lazy dog
.
.
rab
Read 1024 bytes out of 1024
>