cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
1,833 Views
Registered: ‎02-07-2011

sysace_fread and new operator

hello 
i try to read a jpg file stored in my CF card into a buffer .
i defined thus buffer as  : unsigned char *buf; then i used the operator new : buf = new unsigned char[5472]
then i use:  lengthOfFile =sysace_fread(buf, 1, jpg_maxsize, fp);
and my processor stacks , i used printf to know when the processor stacks and the processor display the printf after buf = new unsigned char[5472] but didn't diqplay the printf after the fread function
Is there any problem in these two lines with xilinx
I use xilinx 12.2 and ML507 board 
Thank you in advance

0 Kudos
1 Reply
Highlighted
Observer
Observer
1,586 Views
Registered: ‎09-06-2013

Hi! If you find and open the source file of your function sysace_fread (it's in file {your_BSP_folder}\microblaze_0\libsrc\xilfatfs_v1_00_a\src\src\xilfatfs_read.c), you will see, that it's just a wrapper to call read_from_file(), and there the filesize is calculated as follows:

  FileStatus *fs = find_file_status(stream);
filesize = fs->wd->v.child.FileSize;

 So, you may better use this way to calculate the filesize.

 

BTW: I have another problem - I cannot read large files (about 4MBytes) using sysace_fread(), it reads about 30kBytes and return 0 as bytes read. Does anybody know the solution?

UPD: the solution was to increase the cache size in BSP settings for xilfatfs library up to the size of my large files to be read

0 Kudos