Serial Printer on Terminal (Problems)

Leslie Mikesell les at chinet.UUCP
Sat May 7 13:35:24 AEST 1988


In article <293 at blft1.UUCP> gah at 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



More information about the Comp.unix.xenix mailing list