Linux BiTronics device driver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Introduction
~~~~~~~~~~~~

Most - if not any - of Hewlett-Packard's LaserJet(tm) 4 series printers
are equipt with a bi-directional Centronics(tm) interface, called
BiTronics. In the direction host -> printer the interface is compatible
with a normal Centronics interface. In addition, the interface can be
switched to a printer -> host mode. In this mode the host is now able to
read back printer status information etc.

Several BiTronics communication modes are defined, but unfortunatel only
the nibble mode is availabe among all BiTronics interfaces. Nibble mode
means that the information is read from the printer in portions of half
bytes (nibbles).  In addition, each nibble is not read via the data
lines of the Centronics interface, but instead four handshake lines are
used. To ensure that this readback procedure does not interference with
normal host -> printer data transmission, HP has defined and implemented
a relative complex identification, negotiation and termination protocol
between host and printer via the Centronics control and status lines in
there BiTronics printers.

The BiTronics device driver `bt' for Linux implements this protocols on
the host in kernel space as part of a driver for the PC parallel printer
port. Thus the driver enables user space programs (e.g. printer
spoolers) to use bi-directional communication instead of the normal
unidirectional one.


Printers with BiTronics Interface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The driver is only usefull when you have got a printer with BiTronics
interface. And even if you have such a printer and if you are sattisfied
with the normal lp driver, then the bt driver might be of no interest
for you.

According to HP's formerly confidential Feature Comparison Guide (Part#
5962-8749E) the following LaserJet printers are equipt with a BiTronics
interface:

	4 Plus, 4P, 4L, 4Si, 4, 4M Plus, 4MP, 4ML, 4Si MXs and 4M

It is reported that the
	
	4PJ

(a japanese version) is also equipt with a BiTronics interface.
Information about the brand new

	4V and	4MV

is currently not available.

From the HP Printer Job Language Technical Reference Manual (Part#
5961-0636) it can be taken that the following printers/plotters also
support status readback, but it is not told if this is done via a
BiTronics interface:

	LaserJet III Si, DeskJet 1200C, PaintJet XL300, DesignJet 200,
	DesignJet 600 and DesignJet 650C.

Feedback about BiTronics support in the above mentioned printers/
plotters is appriciated.

The first version of the driver was tested by using a cheap LaserJet
4L. 


Features of the Driver
~~~~~~~~~~~~~~~~~~~~~~

	- The driver supports the three standard PC printer ports.

	- It supports only polling, not interrupt driven communicaion.

	- The driver operates as a normal printer driver in 
	  host -> printer mode. 

	- The driver supports BiTronics nibble mode.

	- Mode and direction switching is done automatically and
	  transparent for the user of read()/write() system calls.

	- Host -> printer mode has precendens over printer -> host mode.

	- Error handling and recovery is done automatic.


Installation
~~~~~~~~~~~~

The bt driver has got to be compiled into the kernel, it is not a
loadable module. It was developed and tested with a 1.1.35 kernel [yes,
I know this is 'stone age', but I don't think the current speed of
kernel releases is a VERY bad idea...] It is supposed that the driver
also works on newer kernels (feedback wellcome).

To install the driver you need the normal Linux kernel source code under
/usr/src/linux. The following setup procedure then changes some files in
the kernel source tree:

	- Become superuser (log in as root).

	- If you haven't already done so, go to some temporary directory
	  and extract the archive bt-*.tar.gz (where * stands for the
	  actual version number):

		tar xvfZ bt-*.tar.gz

	- Go to the just unpacked directory:

		cd bt-*

	- Set up the kernel source code for the new driver and
	  prepare the device entries:

		bt-setup

Now your kernel source code is (hopefully) patched appropriately. Then
reconfigure and compile your new kernel like always:

	- Reconfiguration is necessary:

		make config

	- Say 'n' to "Parallel printer support"
	  NOTE: the bt device driver has got some code in it to support
		interworking with the normal lp printer driver, but this
		code is untested and disabled!)

	- Say 'y' to "BiTronics parallel printer support".

	- Compile the new kernel:

		make dep ; make clean ; make

	- Save the old kernel and install the new one
	  NOTE: This depends on your normal system configuration and
		boot procedure.

If everything went well, go ahead:

	- After you have installed the new kernel reboot the system.

		reboot

	  You should see a boot message similar to the following one:

		bt: Experimental BiTronics device driver v... at major # 29
		bt: parallel port at 0x378 is minor device # 1 (bt1)
			:
			.

	  And perhaps a few additional ones (especially messages starting with
	  "+ [bt_". These messages are debugging messages.
	  Ignore them (well of course not if you experience an error).

	- Turn your LaserJet on and try
	
		cat /dev/bt?

	  where ? is the printer port your printer is connected to. You
	  should receive a message like

		@PJL USTATUS DEVICE
		CODE=10001
		DISPLAY=PRINTER READY

	  This message comes directly from your LaserJet.

	- Try a simple test program:

		tst1 /dev/bt?

You are done with the installation. You now might want to reconfigure your 
printer spooling system to take notice of the new readback feature.


History
~~~~~~~
[you are not supposed to read this]

The BiTronics driver became into existens for a simple reason (perhaps
for the same reason Linux exists): It seams to be possible to do it and
I want to prove this.

Of course, a little bit of luck was also necessary. For adapting the
printer driver of a very old word processor to a LaserJet 4 series
printer, I need the font metrics of the printer's font. Unfortunately
today no company ships complete(!) and consices documentation for there
printer products - not even a usefull description of all ESC-commands -,
so I had to get my hands on HP's Developer's Kit for the LaserJet 4
series.  The good news is: you can buy it, the bad news' are: its
expensive (at least if you only need the font metrics) and it took me a
lot of hastle to get an up-to-date copy.

So after I had finished the printer driver, this expensive bulk of
documantation was just getting dusty. The documentation does not
directly include a description of BiTronics, but on one of the
accompaning disks HP included sample source code for several MS-D*S
BiTronics printer drivers. In total not very nice code, but HP did not
clame any ownership of that code and it was just enough to understand
the general mechanisms of BiTronics (at least of the nibble mode).

On one hand I had the necessary information, on the other hand writing
device drivers is not new to me. I already wrote several ones for SunOS
4.1.x and Solaris 2.x. So all I need was a little bit of time to do it.
I hacked it together in a few evenings distributed over several month
and that's exactly how it looks like.

--
$Id: README,v 1.3 1994/10/26 18:23:46 root Exp $
