problem with data stortage in the MFS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem with data stortage in the MFS

295 Views
botaoyang
Contributor II

I want to save some data(Integer data and float data) to SD card using MFS, but the example program (write(fd,buffer,strlen(buffer));) can only save string data, I want to know how to

using the write command to save a variable data in the form of decimal.

thank you!

0 Kudos
1 Reply

206 Views
RadekS
NXP Employee
NXP Employee

Hi Botao,

It depends in which format you want to store these data.

If you want that data could be readable in different system (like PC). You should probably use string form. In this case for example sprinf() function.

sprintf(buffer, "Value of Pi = %f", pi_number);

write(fd,buffer,strlen(buffer));

If you want store numbers directly you can try using for example such case:

uint32_t                              usr_data[10];

len = write(flash_file, usr_data, sizeof(usr_data));

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos