Skip to main content
Apill
Associate III
Oct 12, 2018 1:27 AM UTC
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?

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.
    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    Oct 12, 2018 3:08 AM UTC

    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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

    5 replies

    Tesla DeLorean
    Tesla DeLoreanBest answer
    Guru
    Oct 12, 2018 3:08 AM UTC

    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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Apill
    ApillAuthor
    Associate III
    Oct 24, 2018 9:22 PM UTC

    @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
    Oct 24, 2018 10:21 PM UTC

    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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Apill
    ApillAuthor
    Associate III
    Oct 25, 2018 1:03 PM UTC

    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
    Oct 25, 2018 3:46 PM UTC

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

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..