*BSD News Article 6439


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!ira.uka.de!news.belwue.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!ira.uka.de!chx400!klarenbe
From: klarenbe@chx400.switch.ch (Paul Klarenberg)
Subject: [386BSD] installing the parallel printerthis works!
Message-ID: <1992Oct12.225054.22992@chx400.switch.ch>
Summary: 386BSD installation of parallel printer
Keywords: 386BSD, parallel, printer, lpt
Organization: Swiss Academic and Research Network SWITCH
Date: Mon, 12 Oct 1992 22:50:54 GMT
Lines: 189

[Hi, I'm posting this for a friend. btw I saw several questions on
the group how to install the parallel printer, but all answers were
more or less only postings of drivers, with no "installation guide".
I had the same question myself and did what Reinier describes below
and it works! Minor remarks from me at the end.

!!this only works if you can recompile the kernel!! PK]

--
Hi Net-ers,

Sorry I may not be such a Unix guru as the designers of the lpt
driver, but installing the lpt driver is not as trivial as it may
seem from the supplied documentation.

several steps have to be taken.
1-  The new driver has to be put in the configuration file.
2-  The C-source files must be added to the files file of
    Config so config can find the file when producing the
    Makefile.
3-  A major number has to be created for lpt.
4-  Config the new config file.
5-  Make depend
6-  Make the new kernel.
7-  Save old kernel and move new kernel.
8-  REBOOT!
9-  mknod new device file.

 As I stated earlier I do not have a full understanding
of the internal working of the Unix kernal, so probably
some things here might be wrong. Let me know!
All I know is that these steps got LPT working for me.

So How to Install

1-  The new driver has to be put in the configuration file.
    Add a line in configfile /sys/i386/conf/YOURKERNAL:

    device     lpt1  at isa? port "IO_LPT1" irq 7 vector lptintr

    An interrupt must be given. It is not used by the driver,
    but must be present for the probe functions to work. (so I
    believe?? )

2-  Copy one of the two lpt drivers (lpt.c) that were posted on the
    group in September (we only tried the one of Andy Velencia, which
    is a modified version of Wolfgang Stranglmeier) into directory
        /sys/i386/isa
    (you might want to save the old lpt.c first)

3-  The C-source files must be added to the files file of
    Config so config can find the file when producing the
    Makefile.
    Add Line to /sys/i386/conf/files.i386:

    i386/isa/lpt.c      optional  lpt  device-driver

4-  A major number has to be created for lpt.
    edit the file /sys/i386/i386/conf.c to add a new
    initializer to the cdevsw[] array. By adding to the end of
    this array your major number will become 14. (Adding somewhere
    else will shift the major numbers of all devices below LPT!)

    First declare the lpt functions by adding after the last #endif
    of the Com declarations (line 166) :

    #include "lpt.h"
    #if NLPT > 0
    int    lptopen(), lptclose(), lptwrite();
    #define lptreset   enxio
    extern struct tty lpt_tty[];
    #else
    #define lptopen  enxio
    #define lptclose enxio
    #define lptwrite enxio
    #define lptreset enxio
    #define lpt_tty  enxio
    #endif

    then add as a *last* entry, the new initalizer to cdevsw[]:

        { lptopen,   lptclose,  enodev,   lptwrite,    /*E*/
          enodev,    enodev,    lptreset, NULL,
          seltrue,   enodev,    NULL},

5-  Config the new config file.
     Create a new make file with:
     cd /sys/i386/conf
     config YOURKERNEL

6-  Make depend:
     cd /sys/compile/YOURKERNEL
     make depend

7-  Make the new kernel:
     make

8-  Save old kernel and move new kernal.
     mv /386bsd /386bsd.old
     mv /sys/compile/YOURKERNEL/386bsd /386bsd

     This allows to use the fixit floppy to restore this
     known-to-work kernel in case the new one fails.

9-  REBOOT!
     shutdown -r now

    Yep do it! and boot with the new kernel.

10-  mknod new device file.
      cd /dev
      mknod lpt1 c 14 17

    for other flavors of minor numbers see exerpt from lpt manual:
    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)


10- test it:
      cat /etc/passwd > /dev/lpt1

    should print something. Lines may not start on left side of
    page because unix ends lines with just LF.


This works, but is this the preferable solution?  What should be
in the cdevsw[] array for the the values other than open/close/write
? (I put in enxio!?).  Is there a simpler solution to the problem?
I you have any comments to this you're  welcome to reply to me
directly, or otherwise Paul will forward your response on the group
to me.  Summary no question.

kind regards,

Reinier Kleipool
Kleipoo@hp.hp.400net.nl

--
[small comment from Paul]
What I can add to that: after doing the "cat /etc..." test you'll
probably have to reset the printer before embarking on the next
test.  Secondly the LF problem is solved for an HP DeskJet 500,
and therefore probably all HP printers, by defining a /etc/printcap
entry and an output filter like below:

/etc/printcap entry:

lp|local parallel line printer:\
	:lp=/dev/lpt1:\
	:sd=/var/spool/lpd:\
	:lf=/var/log/lpd-errs:\
	:if=/usr/lib/filters/iffil:

iffil script:

#!/bin/csh
#
# iffil - lpd input filter for the HP DeskJet 500

# reset printer
printf "\033e"
# line termination: CR => CR, LF => CR + LF, FF => CR + FF
printf "\033&k2G"
# copy input to printer
cat -
# reset printer on exit
printf "\033E"
# return 0 to lpd
exit 0

Make sure you have the x-bits of the script set by e.g.
chmod a+x /usr/lib/filters/iffil