Skip to main content
Apill
Associate III
October 12, 2018
Solved

While integrating SD card with Stm32 in SDIO, FATFS. How can i make the text enter in new line? and also how can i save an integer not characther, How can that be feasible?

  • October 12, 2018
  • 3 replies
  • 1424 views

I am referring to FATFS library

1.I tried to use \n and \t it didnt work. i wanted to make text appear in a new line.

2. in the memory card i wanted to store a vairable integer, How can i do that? As of now i could able to save only character.

In FATFS is there any other way i can save data apart from .txt file?

    This topic has been closed for replies.
    Best answer by Tesla DeLorean

    How do you normally do file IO with STDIO functions? FATFS is pretty similar.

    Use \r\n

    int x = 1234;

    f_write(&fil, &x, sizeof(x), &byteswritten); // pretty inefficient

    >>In FATFS is there any other way i can save data apart from .txt file?

    f_write() writes binary data, it doesn't know you're using a text file.

    Name files how you want.

    Write the content you want.

    3 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    October 12, 2018

    How do you normally do file IO with STDIO functions? FATFS is pretty similar.

    Use \r\n

    int x = 1234;

    f_write(&fil, &x, sizeof(x), &byteswritten); // pretty inefficient

    >>In FATFS is there any other way i can save data apart from .txt file?

    f_write() writes binary data, it doesn't know you're using a text file.

    Name files how you want.

    Write the content you want.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Apill
    ApillAuthor
    Associate III
    October 24, 2018

    @Community member​ , i have exactly used the above mentioned lines. I have got the output as below;

     Ò 

    I tried to output to .txt file and .binary file. the same issue. Any suggestions please

    Tesla DeLorean
    Guru
    October 24, 2018

    File content does not depend on the naming.

    Files are a collection of bytes.

    Data stored in a native binary form does not appear in human readable ASCII.

    Use a file viewer or hex editor to review the content of a file.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Apill
    ApillAuthor
    Associate III
    October 25, 2018

    if i write the following:

    char myData [] = " hello ashok\0";

    f_write(&myFILE, myData, sizeof(myData), &testByte);

    The output of the above is:

    hello ashok.

    How can it differ from characther to numbers

    Tesla DeLorean
    Guru
    October 25, 2018

    Certainly indicative of a problem at the SDIO or FATFS levels.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..