cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
cerilet
Explorer
Explorer
5,670 Views
Registered: ‎08-26-2014

Read double-precision data from SD card

Jump to solution

Hello,

 

I am using SDK to program a standalone application to run on the ARM. I am trying to read double-precision floating-point data written by Matlab in the SD card, process the data, and write it back to the SD card.

 

What I do first (on Matlab) is convert the double format (64-bit) to uint8 and write this data to a file located on the SD card with the command:

 

 fwrite(fid,typecast(data,'uint8'),'uint8');

Apparently, the data is written properly. The problem arises when I read this data using the f_read of the xilffs library. When it finds a 10 (which ASCII value corresponds to a new line), it skips this value and reads the next, corrupting all the data after that.

 

What can I do to overcome this problem? By the way, in Matlab occours the same problem when using fread.

Thanks!
0 Kudos
1 Solution

Accepted Solutions
cerilet
Explorer
Explorer
9,982 Views
Registered: ‎08-26-2014

Ok, problem solved.

 

In Matlab I was opening the file to write the data using the 'wt' option:

fid = fopen('asdf.txt','wt');

 

When using the 'wt' option, the file is opened as a text file. I solved the problem by removing the 't' and like it is a binary file, I used another extension to save the file:

fid = fopen('data.dat','w');

Now I do not have problems when reading an ASCII _new line_ character.

 

Cheers!

View solution in original post

0 Kudos
3 Replies
cerilet
Explorer
Explorer
9,983 Views
Registered: ‎08-26-2014

Ok, problem solved.

 

In Matlab I was opening the file to write the data using the 'wt' option:

fid = fopen('asdf.txt','wt');

 

When using the 'wt' option, the file is opened as a text file. I solved the problem by removing the 't' and like it is a binary file, I used another extension to save the file:

fid = fopen('data.dat','w');

Now I do not have problems when reading an ASCII _new line_ character.

 

Cheers!

View solution in original post

0 Kudos
jianmingli1
Adventurer
Adventurer
2,176 Views
Registered: ‎07-09-2017

@cerilet

 

Hey friend,

 

may I ask you a question about reading double from sd card? I see your idea is great. 

After you convert the double data to uint8 and reading the data, how do you convert the data back to double in SDK?

 

I am trying to read double data from sd card and convert to u32, then do some processing. 

 

And I was using am example .c file from Xilinx SDK installation folder (attached below). In the example, the data type for reading is u8. Do you know how should I modify it? 

 

data i.e.:

-9.7656250000000000e-04
4.8828125000000000e-04
6.8359375000000000e-03
-2.9296875000000000e-03

 

Regards

0 Kudos
1,557 Views
Registered: ‎04-23-2018

Hi All,

 I am also facing same problem .Can  anyone help ?

 

Regards,

sarath

0 Kudos