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.

CCS fopen not working...

Other Parts Discussed in Thread: OMAP3530

 

I am writing code for the omap3530 DSP and would like to read a txt file. When I use fopen to open the file it returns a File * to the opened  file but based on the memory content of the File * there is nothing in the file.


#include <stdio.h>

void uint_read_file(const char* const filename, _iq19* const data, const uint16_t dataSize) {

    if (filename != 0 && data!= 0) {

        FILE* const file = fopen(filename, "r");

        if (file != 0) {
            uint16_t index;
            for (index= 0; index< dataSize; ++index) {
                float value = 0;
                const int SCAN_COUNT = fscanf(file, "%f", &value);
                if (SCAN_COUNT == 1) {
                    filename[index] = _FtoIQ19(value);
                }
            }
            /* close the file */
            fclose(file);
        }
    }
}

After the fopen statement I see the following contents in the File * in the watch window:

file    0x1080CE48    FILE *    hex    NotEdited
     fd    0x00000003    int    hex    NotEdited
     buf    0x00000000 "\021"    unsigned char *    hex    NotEdited
     pos    0x00000000 "\021"    unsigned char *    hex    NotEdited
     bufend    0x00000000 "\021"    unsigned char *    hex    NotEdited
     buff_stop    0x00000000 "\021"    unsigned char *    hex    NotEdited
     flags    0x00000011    unsigned int    hex    NotEdited

Couple of observation:

1) "pos" should not be equal to "bufend" right following the executing of the fopen statement

2) the fscanf statement in the code returns a value of -1 when it tries to scan the File *

3) I have confirmed that there is data in the file

 

Does CCS support fopen?

Why does it not read the text file in properly?

 

thanks