[ECOS] Problem with getchar / gets / fgets

Nicolas Brouard nicolas.brouard@silicomp.ca
Tue Sep 14 19:59:00 GMT 2004

This program behaves perfectly too for me on Powerpc simulator or on linux.
But with my powerpc MPC860 target, I have to hit each character several
times to display it on minicom.
At the end of the line, I have to hit several times ENTER. When ENTER is
take into account, the printf("%s", line); works perfectly...

I think it's a problem of communication on the serial port. It seems to be
the configuration of my ecos library.

But my RedBoot shell works perfectly!


-----Original Message-----
From: Gary Thomas [mailto:gary@mlbassoc.com]
Sent: Tuesday, September 14, 2004 3:38 PM
To: Nicolas Brouard
Cc: eCos Discussion
Subject: Re: [ECOS] Problem with getchar / gets / fgets

On Tue, 2004-09-14 at 12:37, Nicolas Brouard wrote:
> Hi,
> I'm using a board based on a MPC860 processor.
> I try to make a shell application, but the getchar function (or gets, or
> fgets(stdin)) doesn't work very well. Each character requires to be hit
> about 5 to 10 times after which it shows up.
> The test I did is very simple and works perfectly with the powerpc
> target (psim).
> ------------------------------
> #include <stdio.h>
> static char line[256];
> int main(void)
> {
>     printf("hello\n");
>     while(1)
>     {
>         printf("toto> ");
>         gets(line);
>         printf("%s", line);
>     }
>     return 0;
> }
> ------------------------------
> The same problem was posted before in the mailing list, and nobody
> http://sources.redhat.com/ml/ecos-discuss/2003-12/msg00321.html
> Does anybody have an idea about that?

This program behaves perfectly - I just ran it on my Adder (PowerPC 852)

I think the behaviour you are seeing is that gets() and getchar() are
line-oriented, buffered calls.  Input is only sent on to the program
once a carriage return (newline, '\n') has been entered.

Here's the output I got:
RedBoot> l a.t
Using default protocol (TFTP)
Entry point: 0x00040000, address range: 0x00040000-0x0007f6c8
RedBoot> g
toto> this is a test
this is a test
toto> hello, world!
hello, world!
toto> adef

Note: the message you quoted from last December shows exactly the
same behaviour.

Gary Thomas <gary@mlbassoc.com>
MLB Associates

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list