This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C1294NCPDT: Open a file with variable name in Fatfs operation

Part Number: TM4C1294NCPDT


Tool/software: TI C/C++ Compiler

Hello,

I work around Tiva C 1294 launchpad and SD card for a project of data-logger. General overview of my SD card operation is like below:

iFResult = f_mount(0, &g_sFatFs);
if(iFResult != FR_OK)
{
// UARTprintf("f_mount error: %s\n", StringFromFResult(iFResult));
return(1);
}
iFResult = f_open(&g_sFileObject, "a.txt", FA_CREATE_NEW);

The thing I want to try is change "a.txt" to a dynamic file name which can be changed during run-time.

Problem is the f_open accepts only 'const TCHAR' datatype, how can be this achieved?

Example of file name every day i wish to add according to time : May1st.csv , May2st.csv etc

  • Take a look at the implementation done in sd_card.c (C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\dk-tm4c129x\sd_card). The string "g_pcTmpBuf" is declared in line 99.

    static char g_pcTmpBuf[PATH_BUF_SIZE];
    

    There is a call to f_open in line 1274.

        //
        // Now finally, append the file name to result in a fully specified file.
        //
        strcat(g_pcTmpBuf, argv[1]);
    
        //
        // Open the file for reading.
        //
        iFResult = f_open(&g_sFileObject, g_pcTmpBuf, FA_READ);
    

    It is the pointer that is constant, not the characters in the string that is pointed to.