UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Participant stefanoribes
Participant
1,251 Views
Registered: ‎07-25-2016

SDK 2017.2 large file on stdin

Hi everyone,

I'm debugging a C++ bare-metal application on a Zynq ZC702 board. Since I need to read some data from a file, I decided to redirect stdin to a file in workspace. In doing so, I setup the proper "Run Configuration" settings (see figure).

 

run_config.png

 

In my code, I then simply use the scanf() (or fscanf()) function, as follows:

 

 

[...]

scanf("%d", &no_of_nodes);
printf("no_of_nodes = %d\n", no_of_nodes);

int start, edgeno;   

// initalize the memory
for( unsigned int i = 0; i < no_of_nodes; i++) 
{
	fscanf(stdin, "%d %d",&start,&edgeno);
	h_graph_nodes[i].starting = start;
	h_graph_nodes[i].no_of_edges = edgeno;
}

[...]

 

So far I'm able to read the initial value (no_of_nodes) and a bunch of elements without any problem.

 

The problem arises in the for loop: after an unspecified number of elements, I start reading totally wrong values.

The application runs till the end, but the results are definitely not correct.

 

My question is then: why is this happening? Is it related to the dimension of the file, being around 190KB?

 

Would you have any suggestion to solve this issue or, even better, suggest me a way to read files in bare-metal applications?

 

Thanks in advance,

 

Stefano

 

0 Kudos