public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Trouble doing serial console I/O in C++
@ 2007-07-27 21:22 Paul D. DeRocco
  0 siblings, 0 replies; only message in thread
From: Paul D. DeRocco @ 2007-07-27 21:22 UTC (permalink / raw)
  To: 'ecos-discuss'

System: EB40A (ARM7), RAM app debugged over 1st serial port. eCos includes
both tty and termios drivers for the second serial port. I'm trying to do
ordinary console-like line-at-a-time I/O using C++ fstreams. The obvious
way:

	fstream* f = new fstream("/dev/tty1");
	string l;
	getline(f, l, '\n');

doesn't work, because it waits for me to enter 256 characters, rather than
terminating the read on the Enter key. That problem is occurring in fread(),
since it repeatedly reads until it gets the total requested number of bytes.
That seems wrong. It also echoes everything as I type, and then a second
time when it has read the 256 characters. (No, my terminal program is NOT
configured for local echo.)

I tried

	char b;
	f->rdbuf()->pubsetbuf(&b, 1);

That makes it respond correctly to the Enter key, since the fstream is doing
single-character fread() calls, but it echoes each individual character
twice, and also for some reason the backspace doesn't work.

I've tried termios, and it does the same thing, although backspace is even
buggier. I've tried opening a separate ifstream and ofstream. I've tried
tying the ifstream and the ofstream. Nothing works right.

Has anyone figured out how to get fstreams on serial ports to work
correctly? Or is there a way to get cin and cout to map to this device?
(What the heck to cin/cout, or for that matter stdin/stdout, connect to,
anyway?)

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
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] only message in thread

only message in thread, other threads:[~2007-07-27 21:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-27 21:22 [ECOS] Trouble doing serial console I/O in C++ Paul D. DeRocco

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