DSPRelated.com
Forums

read a text file in CCS5416

Started by megha daga April 13, 2006
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

---------------------------------
Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2/min with Yahoo! Messenger with Voice.
in CCS you can't open and read from the file. You have
to keep a probe point at the required location and you
have to read from the file at that point to the
specified buffer with specified number of values.

Steps:

Step1 -> In ccs, keep a probe point just before the
function in which the parameter required is from the
file
Step2 -> Read to the buffer from the specified file at
that probe point.

Regards
Sridhar. A
--- 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
>
> ---------------------------------
> Love cheap thrills? Enjoy PC-to-Phone calls to 30+
> countries for just 2/min with Yahoo! Messenger with
Voice.

__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/
Hi,

Please follow the below steps, may fix your problem,

1. Place 8chF.prm file in Debug folder.
2. Place .cio section in internal memory in .cmd file.
3. Place rts.lib(.text) in internal memory.
4. Check stack and heap sizes.
5. Include stdio.h and string.h header files

If the above steps doesn't fix your problem than try
splitting the memory sections.
Place the rts.lib code in a seperate page.

Hope this helps you to resolve the problem.

Cheers :))
-Lakshman

--- Artham Sridhar wrote:

> in CCS you can't open and read from the file. You
> have
> to keep a probe point at the required location and
> you
> have to read from the file at that point to the
> specified buffer with specified number of values.
>
> Steps:
>
> Step1 -> In ccs, keep a probe point just before the
> function in which the parameter required is from the
> file
> Step2 -> Read to the buffer from the specified file
> at
> that probe point.
>
> Regards
> Sridhar. A
> --- 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
> >
> >
> >
> > ---------------------------------
> > Love cheap thrills? Enjoy PC-to-Phone calls to
> 30+
> > countries for just 2/min with Yahoo! Messenger
> with
> Voice.
>
>
>
__________________________________________________________
> Yahoo! India Answers: Share what you know. Learn
> something new
> http://in.answers.yahoo.com/
>
__________________________________________________