*BSD News Article 5966


Return to BSD News archive

Path: sserve!manuel!munnari.oz.au!network.ucsd.edu!pacbell.com!charon.amdahl.com!amdahl!JUTS!phoenix!gpw10
From: gpw10@phoenixcd.amdahl.com (Gary Ward)
Newsgroups: comp.unix.bsd
Subject: Re: How to get parallel printer to work ?
Keywords: parallel printer 386bsd lpt1
Message-ID: <66YV02cj24MG01@JUTS.ccc.amdahl.com>
Date: 1 Oct 92 18:08:12 GMT
References: <BvEp92.91@news.cso.uiuc.edu>
Sender: netnews@ccc.amdahl.com
Organization: Amdahl Corporation, Sunnyvale CA
Lines: 264

Since this has been coming up a lot, I thought I would post this
rather than replying by E-mail.  Perhaps this information should be
added to the FAQ?  (There is no reference to it in the latest version
I have.)

The lpt (parallel port) driver is not configured into the kernel by
default.  This must be added and the kernel rebuilt before the device
will be accessable.  In addition, the original driver appears to have
problems.  Some people have reported being able to get it to work, I
was unable to.  An alternate driver was posted to comp.unix.bsd a
while back.  That driver, and the associated articles are included
below.  This driver has been working very well for me.


I also have a HP DeskJet 500.  This printer expects <CR><LF> at the
end of each line.  I provided a simple output filter to add the needed
<CR> characters and it would then print text fine.  Unfortunately
doing this screws up graphics printing.  I therefore invented another
logical printer which does not filter and dump all my graphics to it.
The better solution would be to implement a filter which recognizes
the graphics escape sequences and suppresses insertion of <CR>s while
in graphics mode, but I haven't gotten around to writing it yet.
Following are my /etc/printcap file and the source for the output
filter.  Note that my printcap file also suppresses burst pages (sh
option).  For a single user system, they were a waste of paper.  If
you have multiple users, you may want this enabled.

Note that the printcap file and filter programs are specific to my
printer.  If you have a different printer, they may not work, or may
even screw you up.  The lpt driver should not be printer specific.

----------------------------------------------------------------------
#       @(#)printcap    5.3 (Berkeley) 6/30/90

lp|local line printer:\
       
:lp=/dev/lp:sd=/var/spool/lpd:lf=/var/log/lpd-errs:sh:of=/usr/local/bin/
/lpr_filter:

lpnf|local line printer NO FILTER:\
        :lp=/dev/lp:sd=/var/spool/lpd:lf=/var/log/lpd-errs:sh:
----------------------------------------------------------------------
#include <stdio.h>

#define CR    13

main()
{
  int c;

  while ( (c = getchar()) != EOF ) {
    switch ( c ) {
    case '\n':
      putchar(CR);
      /* fall through */

    default:
      putchar(c);
    }
  }

  return(0);
}
----------------------------------------------------------------------

From: wolf@dentaro.GUN.de (Wolfgang Stanglmeier)
Newsgroups: comp.unix.bsd
Subject: replacement for lpt.c without interrupts
Date: 6 Sep 92 14:37:03 GMT
Organization: Colognists, Germany

I hacked the 386bsd LPT-driver to work without interrupts.
The busy loop timeout value adapts automatically to
the printer and system speed.

It should be a full replacement for the standard driver.

This driver keeps my printer busy without slowing down the system.
[I remember the 90% system time when printing hppcl graphic files
 with the ix/386 lpt-driver WITH interrupts]

The driver supports up to 4 printers.
The minor number is interpreted as follows:

	D D P E - - # #

DD:	Debug,	00: no
		01: statistical data when closing device
		10: statistical data for every write call
		11: lots of silly data

P:	Prime on open.

E:	Errormessage.
		Logs "no paper", "offline", "printer error" conditions
		to the console.

##:	Device,	0: lpt0
		1: lpt1
		2: lpt2		(on display adapter)

This driver uses the ideas of Piercarlo Grandis polling printer driver.

----------------------------------------------------------------------

From: ajv@xhost92.csd.mot.com
Newsgroups: comp.unix.bsd
Subject: Re: replacement for lpt.c without interrupts
Date: 9 Sep 92 06:00:18 GMT

wolf@dentaro.GUN.de (Wolfgang Stanglmeier) writes:

>I hacked the 386bsd LPT-driver to work without interrupts.
>The busy loop timeout value adapts automatically to
>the printer and system speed.

<excellent driver follows...>

I was working on something very much along the same lines.  However,
Mr. Stanglmeier hit the nail right on the head first.  I have rolled
in some of my other work on handling syscall restarts, and in the
process applied my BSD-kernel style of indentation.  What follows is
substantially the same driver, with my own minor improvements.

Kudos, Mr. Stanglmeier!  My printer thanks you. :-)

					Andy Valencia
					ajv@csd.mot.com (for now)
					jtk@netcom.com (if it bounces)

-----------------------------------------------------------------------

begin 644 lpt.c.Z
M'YV0+U0H *$"Q) W</+(27,&#1T0*,:D !$C1PX8(*ZD8<,F39@V((RX *'D
M34<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------------------------+---------------------------+
| Gary Ward              |  Amdahl Corporation       |
| gpw10@cd.amdahl.com    |  1250 East Arques Avenue  |
| Phone : (408)746-8865  |  P.O. Box 3470 M/S 142    |
|                        |  Sunnyvale, CA 94088-3470 | 
+------------------------+---------------------------+