problem with data stortage in the MFS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

problem with data stortage in the MFS

652 次查看
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 项奖励
回复
1 回复

563 次查看
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 项奖励
回复