cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
7,468 Views
Registered: ‎09-11-2007

How to transplant general c program to edk c program.

Hello everyone,
I have encountered a problem when transplant a c program to edk c program.
My development board is ML401 with SysACE CF controller.
 
The problem is that in WINDOWS VC environment, open, read or getc operation to a file on file system can use <stdio.h> lib.
But in EDK c, where files are stored on CF card, there are only 4 main functions, sysace_fopen, sysace_fread, sysace_fwrite, sysace_fclose, can adopt to deal with files.
 
Many functions in original c program such as fseek, getc, fprintf couldn't used to deal with files on CF card.
 
So if anyone has some ideas to make such functions fseek, getc, fread available to deal with file on CF card,
please give the suggestions to me.
 
Best Wishes!
0 Kudos
Reply
1 Reply
Newbie
Newbie
7,440 Views
Registered: ‎10-12-2007

You actually everything that you need, the sysace_fread (i have not looked into its documentation) should allow you to build a fseek function that reads from the beginning or the current position in the file. Exactly the same is true for the getc; just write a function that reads 1 character and returns it.
fprintf could prove a little harder if you want to implement the variable parameters feature yourself but you can use the sprintf function to write everything to your string and you can use fprintf afterwards. However be aware that the standard printf function takes up a lot of code size. There is a xil_printf function but this does not support every feature of the normal printf function.

Hope this helps,
regards,
Chris
0 Kudos
Reply