* [ECOS] Problem with printf
@ 2004-05-18 9:02 Sidharth Jandhyala
2004-05-18 11:38 ` Nick Garnett
0 siblings, 1 reply; 5+ messages in thread
From: Sidharth Jandhyala @ 2004-05-18 9:02 UTC (permalink / raw)
To: ecos-discuss; +Cc: gokhan
Hi,
I am having a peculiar problem with printf. I noticed that a newline '\n'
must be placed at the end of each printf statement to work. How do I get
around this problem? Here is s sample code
I am using the eb40A board and debugging using arm-elf-insight.
//---------------------------------------------------------
# include <cyg/kernel/kapi.h>
# include <stdio.h>
# include <stdlib.h>
int main (int agrc, char * argv[])
{
printf("1.HEllo world..........\n");
printf("\n2.Hello world again");
printf("3.Hello world again");
} //End main
//---------------------------------------------------------
The output is
//---------------------------------------------------------
1.HEllo world..........
//---------------------------------------------------------
Why has eCos been implemented such that the '\n' must be included at the end
of the printf statement. Is there a way to avoid this characteristic. Is
there a way to flush the print buffers other than looking for the '\n'.
Thanks in advance.
Regards,
Sidharth
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Problem with printf
2004-05-18 9:02 [ECOS] Problem with printf Sidharth Jandhyala
@ 2004-05-18 11:38 ` Nick Garnett
2004-05-19 8:07 ` Sidharth Jandhyala
2004-05-31 10:41 ` Gokhan
0 siblings, 2 replies; 5+ messages in thread
From: Nick Garnett @ 2004-05-18 11:38 UTC (permalink / raw)
To: sidharth; +Cc: ecos-discuss, gokhan
"Sidharth Jandhyala" <sidharth@clarinox.com> writes:
> Why has eCos been implemented such that the '\n' must be included at the end
> of the printf statement. Is there a way to avoid this characteristic. Is
> there a way to flush the print buffers other than looking for the '\n'.
This is standard C library behaviour. The library buffers all output
characters internally until either the buffer is full or, for line
buffered streams, a newline is output. If you want to cause buffered
data to be output before either of those conditions occurs, use
fflush(stdout).
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [ECOS] Problem with printf
2004-05-18 11:38 ` Nick Garnett
@ 2004-05-19 8:07 ` Sidharth Jandhyala
2004-05-19 9:39 ` sandeep
2004-05-31 10:41 ` Gokhan
1 sibling, 1 reply; 5+ messages in thread
From: Sidharth Jandhyala @ 2004-05-19 8:07 UTC (permalink / raw)
To: 'Nick Garnett'; +Cc: ecos-discuss, gokhan
Hi Nick,
I am still having a problem with the printf. I tried fflush as you
suggested.
//--------------------------------------------------------------------------
# include <stdio.h>
# include <stdlib.h>
int main (int agrc, char * argv[])
{
printf("1.Hello World\n");
printf("Hello fflush");
fflush(stdout);
} //End main
//--------------------------------------------------------------------------
The output I get is
//--------------------------------------------------------------------------
1. Hello world
//--------------------------------------------------------------------------
I have the latest CVS. Any suggestions??
-------------Sidharth
-----Original Message-----
From: nickg@miso.calivar.com [mailto:nickg@miso.calivar.com] On Behalf Of
Nick Garnett
Sent: Tuesday, 18 May 2004 7:02 PM
To: sidharth@clarinox.com
Cc: ecos-discuss@sources.redhat.com; gokhan@clarinox.com
Subject: Re: [ECOS] Problem with printf
"Sidharth Jandhyala" <sidharth@clarinox.com> writes:
> Why has eCos been implemented such that the '\n' must be included at the
end
> of the printf statement. Is there a way to avoid this characteristic. Is
> there a way to flush the print buffers other than looking for the '\n'.
This is standard C library behaviour. The library buffers all output
characters internally until either the buffer is full or, for line
buffered streams, a newline is output. If you want to cause buffered
data to be output before either of those conditions occurs, use
fflush(stdout).
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Problem with printf
2004-05-19 8:07 ` Sidharth Jandhyala
@ 2004-05-19 9:39 ` sandeep
0 siblings, 0 replies; 5+ messages in thread
From: sandeep @ 2004-05-19 9:39 UTC (permalink / raw)
To: sidharth; +Cc: ecos-discuss
Sidharth,
have a look at the documentation (man pages on any linux installation will be
easy enough) of setbuf, setvbuf family of functions, these are present in eCos
too.you can try
{
setbuf (stdout, NULL);
printf ("Hello World\n");
printf ("Hello fflush");
}
if above also doesn't work, then you need to investigate things deeper down,
tracing the second printf call
I wonder why fflush(stdout) is not doing the job.
--
regards
sandeep
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [ECOS] Problem with printf
2004-05-18 11:38 ` Nick Garnett
2004-05-19 8:07 ` Sidharth Jandhyala
@ 2004-05-31 10:41 ` Gokhan
1 sibling, 0 replies; 5+ messages in thread
From: Gokhan @ 2004-05-31 10:41 UTC (permalink / raw)
To: 'Nick Garnett', sidharth; +Cc: ecos-discuss
Fflush seems like not working for EB40A ( unless we are making a silly
mistake ). Is there any setting that could have missed during the
configuration?
Thanks in advance,
Gokhan Tanyeri
www.clarinox.com
-----Original Message-----
From: nickg@miso.calivar.com [mailto:nickg@miso.calivar.com] On Behalf
Of Nick Garnett
Sent: Tuesday, May 18, 2004 7:02 PM
To: sidharth@clarinox.com
Cc: ecos-discuss@sources.redhat.com; gokhan@clarinox.com
Subject: Re: [ECOS] Problem with printf
"Sidharth Jandhyala" <sidharth@clarinox.com> writes:
> Why has eCos been implemented such that the '\n' must be included at
> the end of the printf statement. Is there a way to avoid this
> characteristic. Is there a way to flush the print buffers other than
> looking for the '\n'.
This is standard C library behaviour. The library buffers all output
characters internally until either the buffer is full or, for line
buffered streams, a newline is output. If you want to cause buffered
data to be output before either of those conditions occurs, use
fflush(stdout).
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-05-31 8:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-18 9:02 [ECOS] Problem with printf Sidharth Jandhyala
2004-05-18 11:38 ` Nick Garnett
2004-05-19 8:07 ` Sidharth Jandhyala
2004-05-19 9:39 ` sandeep
2004-05-31 10:41 ` Gokhan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).