View Single Post
  #1 (permalink)  
Old 12-14-2007, 09:47 AM
Bathala
Guest
 
Posts: n/a
Default using fstream to access File on Compact Flash Card

Specification
EDK version:8.2i
FPGA Board: Virtex II Pro
Compiler : mb-g++

I'm tring to create a file stream using ifstream instr("ba1.bits")
or ifstream instr("a:\\ba1.bits") to create a file stream from
CF card.

In addition I've added #include <stdio.h> which is necessary to
ensure that microblaze compiler recognizes the the c++ sections of
code.

I've amended the file ....\EDK\sw\lib\sw_services\xilfatfs_v1_00_a
\src\include\sysace_stdio.h uncommenting the following lines

#define SYSACE_FILE FILE
// typedef void FILE;

#define fopen sysace_fopen
#define fclose sysace_fclose
#define fread sysace_fread
#define fwrite sysace_fwrite

File cannot be read...

Alternatively I tried using sysace_fopen directly -> char array ->
streambuf


streambuf * pbuf;

void myrun(void * mybuf) {
sysace_fread( (void *) mybuf, 1, 1, outfile);
// pbuf->sputn (charbuffin,sizeof(charbuffin)-1);
}


Int main (){
void *mainbuf;

if ((outfile = sysace_fopen("file.txt", "r")) == NULL)
{
xil_printf("Couldn't open the file\r\n");
}
else{

for (int i=0;i<4;i++){
myrun(mainbuf);
pbuf->sputc( (char *) mainbuf);
usleep(1000);
}
return 0;
}

System hangs at this point.........

Please do let me know how file from CF card ->input stream?

Priyantha


Reply With Quote