Path: utzoo!mnetor!uunet!husc6!rutgers!mcdchg!chinet!les
From: les@chinet.UUCP (Leslie Mikesell)
Newsgroups: comp.unix.xenix
Subject: Re: Serial Printer on Terminal (Problems)
Message-ID: <5117@chinet.UUCP>
Date: 7 May 88 03:35:24 GMT
References: <293@blft1.UUCP>
Reply-To: les@chinet.UUCP (Leslie Mikesell)
Organization: Chinet - Public Access Unix
Lines: 22
Keywords: xenix 2.2.1

In article <293@blft1.UUCP> gah@blft1.UUCP (Gregg Houck SysOp) writes:
>Am having a small problem using a serial printer off of a remote
>terminal.  Here is the setup:
>...
>and the printer should be off.  What happens is that the question sent to
>the screen shows on the printer.  After this the printer does shut off.

What is happening is that the hardware buffers are holding the "printer-off"
code long enough for the output of the next program to get ahead of it.
You need to add:
  fflush(file);
  ioctl(fileno(file),TCSBRK,1);
to wait for I/O to complete.

If that doesn't work (and it doesn't with some hardware), add a short
sleep() at the end.  Some terminals take a while to respond to control
codes also, so you may have to allow for that with a delay.  Even worse,
some will do buffering for the printer, but will stop immediately when
the "printer-off" code is received without printing the rest of the
buffered data.

   Les Mikesell