Sign in

username:

password:



Not a member?

Search c54x



Search tips

Subscribe to c54x



c54x by Keywords

5409 | 5416 | AD5 | ADC | BIOS | Boot | Booting | Bootloader | C540 | C5402 | C5409 | C5416 | CCS | Codec | DMA | Dmad | DSK | DSKPlus | Dsplib | EVM | FFT | FIR | Flash | GPIO | HPI | Initialization | Interrupt | JTAG | LOG_printf | MCBSP | RFFT | RTDX | Sampling | STLM | UART | VC540


Discussion Groups

Discussion Groups | TMS320C54x | Re: read an external text file in CCS5416

Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).

  

Post a new Thread

Re: read an external text file in CCS5416 - Jeff Brower - Apr 16 12:40:45 2006



Megha-

> I think some or the other time, someone might have read data from an
> external file in CCS. I am trying to do the same.
> As I wrote in previous mail I am reading data from a prm(text) file. I am
> using fopen(), scanf() and functions like that from stdio.h. But CCS is
> not running the program. its not opening the file only.

Did you try an explicit path instead of only "8chF.prm" ?

When this happens, what are the values of errno, and strerror(errno)? 
Maybe you can do a debug printf statement:

  printf("Mega cannot open file! Error %i, %s\n", errno, strerror(errno));

to help figure it out.

-Jeff
> megha daga <m...@yahoo.com> wrote:    hey everyone
> I am working on PEP5416 and using CCS5416 as simulator. Well in my code I
> am reading data from a prm(text) file. I am reading the data and scaning
> it and storing the value as follows:
>
> if( (fileid = fopen( "8chF.prm", "r" )) == NULL )
>     {
>             exit(1);
>     }
>
> while(1)
>     {
>          if(fgets(temp, 250, fileid) == NULL)
>         {
>             exit(1);
>         }
>
>         sscanf(temp, "%s", &temp);
>         if(!strcmp(temp,"NUMCHAN"))
>         {
>              fgets(temp, 250, fileid);
>             sscanf(temp, "%hu", &numchan);
>             break;
>         }
>    }
>
> Well as you will notice I am opening a file and then reading 250 chars and
> seeing where NUMCHAN occurs. As soon as I get the match I store the value
> following in the next 250 chars of NUMCHAN in numchan.
> Well my problem is that simulator is not opening the file only. Its not
> reading the file. When i do step by step debugging, I notice that after
> "fopen" statement the debugger cursor goes to "exit(1)" instead of
> "while". I have included the proper header file too (stdio.h). Well the
> prm file is stored inside the same folder. Everything is there. there is
> no building error. I dont understand why its doing that.
> I hope I am able to expalin my problem.
> Someone kindly reply and help me out.
> Thanking You
> Megha Daga



(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )

Re: read an external text file in CCS5416 - megha daga - Apr 17 10:21:11 2006

dear Jeff
Thanks for replying. Well I did try the printf statement:

if((fileid = fopen( "test", "r" )) == NULL )
    printf( "The file 'test' was not opened\n" );
   else
      printf( "The file 'test' was opened\n" );

while(1)
    {
        if(fgets(temp, 250, fileid) == NULL) 
        {
            exit(1);
        }

        sscanf(temp, "%s", &temp);
        if(!strcmp(temp,"NUMCHAN"))
        {
            fgets(temp, 250, fileid);
            sscanf(temp, "%hu", &numchan);
            break;
        }
        
    }
But then it printed : 
The file 'test' was not opened. 
I also tried what you suggested: to give the whole path for the file but then it printed a
worning statemnet :
"test.c", line 10: warning: unrecognized character escape sequence
And gave the same error while running. I think there is some problem in reading .txt. I read
doc on CCS5416 and it explains how to read .dat files, but it never speaks abt .txt files. And
in my case, i need to read the txt file or something like that.
Someone kindly suggest something.
Kindly help.
Thanking You
Megha Daga

Jeff Brower <j...@signalogic.com> wrote: Megha-

> I think some or the other time, someone might have read data from an
> external file in CCS. I am trying to do the same.
> As I wrote in previous mail I am reading data from a prm(text) file. I am
> using fopen(), scanf() and functions like that from stdio.h. But CCS is
> not running the program. its not opening the file only.

Did you try an explicit path instead of only "8chF.prm" ?

When this happens, what are the values of errno, and strerror(errno)? 
Maybe you can do a debug printf statement:

  printf("Mega cannot open file! Error %i, %s\n", errno, strerror(errno));

to help figure it out.

-Jeff
> megha daga  wrote:    hey everyone
> I am working on PEP5416 and using CCS5416 as simulator. Well in my code I
> am reading data from a prm(text) file. I am reading the data and scaning
> it and storing the value as follows:
>
> if( (fileid = fopen( "8chF.prm", "r" )) == NULL )
>     {
>             exit(1);
>     }
>
> while(1)
>     {
>          if(fgets(temp, 250, fileid) == NULL)
>         {
>             exit(1);
>         }
>
>         sscanf(temp, "%s", &temp);
>         if(!strcmp(temp,"NUMCHAN"))
>         {
>              fgets(temp, 250, fileid);
>             sscanf(temp, "%hu", &numchan);
>             break;
>         }
>    }
>
> Well as you will notice I am opening a file and then reading 250 chars and
> seeing where NUMCHAN occurs. As soon as I get the match I store the value
> following in the next 250 chars of NUMCHAN in numchan.
> Well my problem is that simulator is not opening the file only. Its not
> reading the file. When i do step by step debugging, I notice that after
> "fopen" statement the debugger cursor goes to "exit(1)" instead of
> "while". I have included the proper header file too (stdio.h). Well the
> prm file is stored inside the same folder. Everything is there. there is
> no building error. I dont understand why its doing that.
> I hope I am able to expalin my problem.
> Someone kindly reply and help me out.
> Thanking You
> Megha Daga



(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )