Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lp(4) — RISC iX 1.2

Media Vault

Software Library

Restoration Projects

Artifacts Sought

LP(4)  —  UNIX Programmer’s Manual

NAME

lp − parallel port

DESCRIPTION

The file /dev/lp provides access to the parallel printer port.  The device may only be opened once before the corresponding close, to prevent conflicts of usage. 

Variations in the minor device number enable certain driver options to be selected.  Any of these may later be altered by means of ioctl(2) commands.

The minor device number is composed as follows:

  0
+ 1if no postprocessing is required - if this
bit is set the remaining bits are irrelevant
+ 2if an FF should NOT be sent on open or on
close to eject the final page
+ 4if a CR should NOT be sent before each LF
+ 8to cause TAB to be expanded to spaces
+ 16to restrict printing set to 64 characters
for use with upper-case-only printers.

From the above it can be seen that the standard device /dev/lp (which has minor number 0) acts as a conventional printer interface: a form-feed is sent on open, and on close if the last page is not complete; LF is converted to CR,LF; the printer is assumed to do its own tab-expansion and support full 96-character ASCII.  Opening minor device 1 instead yields a completely raw interface where characters written are transmitted to the printer with no interpretation or modification applied.  Other devices may be defined (using mknod(2)) with any combination of the options as required; it should be noted that there is no point in defining any device with an odd minor number other than 1 as this first option overrides all others. The behaviour of the interface may be modified within the set of options by using the following ioctl(2) commands, defined in <dev/lpioctl.h>, where fd represents a file descriptor open to the device. 

ioctl(fd, PIOCSETMODE, &flags) sets the options according to the value in the int flags: the options derived from the minor device number are forgotten. The flags argument is composed of the bitwise OR of the following constants, which have the same values as the minor device number bits:

LP_NOCANONdisable postprocessing
LP_NOAUTOFF disable opening & possible closing FF
LP_NOACRdon’t generate CR characters prior to LF
LP_TABEXPexpand tabs to spaces (based on tab width 8)
LP_CAPtranslate to upper case

If any bit other than one of these is set, the call will be faulted. 

ioctl(fd, PIOSETLINES, &lines) sets the number of lines per page to the value in the int lines. Unless the no-postprocessing option is selected, this will cause a formfeed character to be generated after each multiple of the given number of lines. A value of 0 causes the line counting to be disabled; this is the state of the setting when the device has just been opened.

ioctl(fd, PIOSETCOLS, &columns) sets the number of columns on the page to the value in the int columns. Unless the no-postprocessing option is selected, this will cause a newline (and possibly a formfeed if the line-counting option is also enabled) to be generated if the number of columns on the line exceeds the given value. A value of 0 causes the column counting to be disabled, which is the initial setting on opening the device.

For programming convenience, one further call is defined: ioctl(fd, PIOCGETMODE, &flags) reads the current option settings into the int flags, allowing individual options to be treated separately in the manner of the standard tty interface (cf. the commands TIOCGETN, TIOCSETN etc., described in tty(4)).

FILES

/dev/lp

BUGS

The column-counting code in the driver is naive about escape sequences and unknown non-printing characters (i.e. it will almost certainly handle them incorrectly).  Such special sequences should be sent with the no-postprocessing option selected. 

4th Berkeley Distribution  —  Revision 1.6 of 24/10/88

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026