public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] mysterious behavior in serial ports
@ 2007-03-02  7:39 Chuck McManis
  2007-03-02  8:01 ` Chuck McManis
  0 siblings, 1 reply; 3+ messages in thread
From: Chuck McManis @ 2007-03-02  7:39 UTC (permalink / raw)
  To: ECOS Discussion Group

So per Andrews comment I found that yes, I can force /dev/tty0 to be 
stdin/out (cool) and as long as I talk to Redboot on COM1 first it becomes 
/dev/ttydiag so no worries about stalling the system by polling the serial 
port.

However, I have a simple loop that goes:
     while (1) {
	char buf[200];

	printf("Enter some text : ");
	gets(buf);
	printf("'%s'\n", buf);
     }

Basically get some text and print it out. The weird behavior is that the 
text doesn't show up, pause .... pop out comes the Enter ..text prompt. 
Start typing and see nothing then suddenly poof! all caught up and 
following my keystrokes in real time.

So I assume this is some sort of high water/ low water buffering behavior. 
Can I turn it off so that text comes out right away and echoes right away?

--Chuck


-- 
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] 3+ messages in thread

* Re: [ECOS] mysterious behavior in serial ports
  2007-03-02  7:39 [ECOS] mysterious behavior in serial ports Chuck McManis
@ 2007-03-02  8:01 ` Chuck McManis
  2007-03-05  7:04   ` wang cui
  0 siblings, 1 reply; 3+ messages in thread
From: Chuck McManis @ 2007-03-02  8:01 UTC (permalink / raw)
  To: ECOS Discussion Group

And a bit more information, I went back and enabled nonblocking on the 
serial driver and that fixes the input (basically it starts echoing as soon 
as I type) but output still pauses. I can fix that by putting an 
fflush(stdout); in there but this is not the behavior my user code is 
expecting and as I'm porting a fairly sizable chunk it seems I should be 
able to get this fixed in ecos instead ;-).

That being said I'm rummaging around the implementation of the standard i/o 
library both on FreeBSD and on ecos to see how they differ in this regard...

--Chuck

At 11:39 PM 3/1/2007, Chuck McManis wrote:
>So per Andrews comment I found that yes, I can force /dev/tty0 to be 
>stdin/out (cool) and as long as I talk to Redboot on COM1 first it becomes 
>/dev/ttydiag so no worries about stalling the system by polling the serial 
>port.
... elided


-- 
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] 3+ messages in thread

* Re: [ECOS] mysterious behavior in serial ports
  2007-03-02  8:01 ` Chuck McManis
@ 2007-03-05  7:04   ` wang cui
  0 siblings, 0 replies; 3+ messages in thread
From: wang cui @ 2007-03-05  7:04 UTC (permalink / raw)
  To: ecos, ecos-discuss

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312; format=flowed, Size: 1895 bytes --]

I think you can add the piece of code below, before you printf something.
-------------------------------------------
#include <stdio.h>

  /* Unbuffer stdio */
  setvbuf(stdout, (char *)NULL, _IONBF, 0);
  setvbuf( stdin, (char *)NULL, _IONBF, 0);
  setvbuf(stderr, (char *)NULL, _IONBF, 0);
-------------------------------------------


>From: Chuck McManis <ecos@mcmanis.com>
>To: ECOS Discussion Group <ecos-discuss@sources.redhat.com>
>Subject: Re: [ECOS] mysterious behavior in serial ports
>Date: Fri, 02 Mar 2007 00:01:25 -0800
>
>And a bit more information, I went back and enabled nonblocking on 
>the serial driver and that fixes the input (basically it starts 
>echoing as soon as I type) but output still pauses. I can fix that 
>by putting an fflush(stdout); in there but this is not the behavior 
>my user code is expecting and as I'm porting a fairly sizable chunk 
>it seems I should be able to get this fixed in ecos instead ;-).
>
>That being said I'm rummaging around the implementation of the 
>standard i/o library both on FreeBSD and on ecos to see how they 
>differ in this regard...
>
>--Chuck
>
>At 11:39 PM 3/1/2007, Chuck McManis wrote:
>>So per Andrews comment I found that yes, I can force /dev/tty0 to 
>>be stdin/out (cool) and as long as I talk to Redboot on COM1 first 
>>it becomes /dev/ttydiag so no worries about stalling the system by 
>>polling the serial port.
>... elided
>
>
>--
>Before posting, please read the FAQ: 
>http://ecos.sourceware.org/fom/ecos
>and search the list archive: 
>http://ecos.sourceware.org/ml/ecos-discuss
>

_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger:  http://messenger.msn.com/cn  


-- 
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] 3+ messages in thread

end of thread, other threads:[~2007-03-05  7:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-02  7:39 [ECOS] mysterious behavior in serial ports Chuck McManis
2007-03-02  8:01 ` Chuck McManis
2007-03-05  7:04   ` wang cui

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).