delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/20/12:47:51

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Parallel Port and printf
Date: Sat, 20 Dec 1997 11:01:30 +0100
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 53
Message-ID: <349B977A.10769BCC@LSTM.Ruhr-UNI-Bochum.De>
References: <Pine DOT SOL DOT 3 DOT 96L DOT 971219231050 DOT 8853A-200000 AT nbc DOT ksu DOT ksu DOT edu>
NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Adam Young wrote:
> 
> Hello,
> 
> I am developing a program that uses the parallel
> port to read a 4-bit BCD number and return the
> decimal value. I am accomplishing this by constantly
> scanning the port and checking for the strobe (DV)
> to go high. Once it goes high, the 4-bit word is
> sent to "conv" to be converted to the corresponding
> decimal value and printed to the screen. This is the
> problem. The "printf" marked with the ???? is needed
> for the numbers to be printed out "real time". If
> I do not have the "printf ("\n");" statement, the
> program only writes to the screen AFTER I hit control-c
> to stop the program. I am using DJGPP and RHIDE to
> develop this program.
> 
> What I want is to print the data to the screen (and,
> later to be logged in a file) in a row (ie. "123456")
> instead of on a new line each time. I am sure this
> is not a problem with DJGPP or RHIDE but a simple
> "error" that I am making. Any help is appreciated.
> Thanks in advance!

The error is that you didn't read the FAQ, chapter
9.4. (Too bad, my newsreader refuses to post this,
so some exlplainations)
DJGPP and most other compilers under decent operating
systems make textfiles buffered, and stdio files line
buffered.Hence, something that goes to stdout
will be seen after a "\n", a certain number of characters
in the output buffer, or an fflush(stdout);
If you do not plan to redirect the screen output
to a file, it might be more efficient to use
cprintf().



-- 
Ciao
Tom

*************************************************************
* Thomas Demmer                                             *
* Lehrstuhl fuer Stroemungsmechanik                         *
* Ruhr-Uni-Bochum                                           *
* Universitaetsstr. 150                                     *
* D-44780  Bochum                                           *
* Tel: +49 234 700 6434                                     *
* Fax: +49 234 709 4162                                     *
* http://www.lstm.ruhr-uni-bochum.de/~demmer                *
*************************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019