From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24049 invoked by alias); 14 Sep 2004 19:37:45 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 24037 invoked from network); 14 Sep 2004 19:37:44 -0000 Received: from unknown (HELO hermes.chez-thomas.org) (63.225.98.241) by sourceware.org with SMTP; 14 Sep 2004 19:37:44 -0000 Received: by hermes.chez-thomas.org (Postfix, from userid 2000) id 4EE01100010; Tue, 14 Sep 2004 13:37:44 -0600 (MDT) Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by hermes.chez-thomas.org (Postfix) with ESMTP id CA53E100007; Tue, 14 Sep 2004 13:37:43 -0600 (MDT) From: Gary Thomas To: Nicolas Brouard Cc: eCos Discussion In-Reply-To: References: Content-Type: text/plain Organization: MLB Associates Message-Id: <1095190663.7891.44.camel@hermes> Mime-Version: 1.0 Date: Tue, 14 Sep 2004 19:37:00 -0000 Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on hermes.chez-thomas.org X-Spam-Level: Subject: Re: [ECOS] Problem with getchar / gets / fgets X-SW-Source: 2004-09/txt/msg00163.txt.bz2 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 simulator > target (psim). > ------------------------------ > #include > 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 answers. > 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 hello toto> this is a test this is a test toto> hello, world! hello, world! toto> adef adef toto> Note: the message you quoted from last December shows exactly the same behaviour. -- Gary Thomas 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