Documentation for HPTools

M.Janson May 1, 1997

Contents

1 What is HPtools 2 2 Rights 2 3 Compiling and Installing 2 4 Usage 3 5 Options 3 6 Commands 4

6.1 Printer Steering . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 6.2 Page Steering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 6.3 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

7 Using special printers 5 8 Usage with filters in printcap 6 9 Using the prompt function 6 10 Next Versions 7 11 Errors 7 12 Thanks 7

1 What is HPtools

HPTools is written to make it simple sending ESC-sequences to the printer. ESC-sequences are printer commands to print in landscape format, small, big and so on. With the help of HPTools these commands are changed into easy to note expressions. The most important reason to use HPTools in LINUX is the fact, that HP printers need a linefeed at the end of every line. This linefeed is unknown in the original ASCII code with Linux. So it will happen, that the printer puts the whole document into one line. There is one printer command solving this problem. It looks like &k2G . With HPTools it changes to cr . All the other commands you can use with HPTools are described in this document. The program was written for the HP560C but it should work with all HP printers, and with a lot of others. It was succesfully used on an OKI Laserline 6 elite .

2 Rights

There is no warranty for the function and correctness of this software package. The use is on your own risk, so I will not pay for any damages arised by this package. The package is free of charge, and you are allowed to copy it, but only in the original condition.

3 Compiling and Installing

To use HPTools you first have to compile it. For doing this you will need an ANSI C - or C++ compiler. Using LINUX you are doing good to use the GNU-C mostly distributed with the LINUX package. First you should edit the Makefile of this package. The needed changes are according to the printer device and the path you want install into. The printer devices are found in the /dev directory. The mostly used is /dev/lp0 , which is the same like LPT1 in MSDOS. But which one you have to use depends on your local machine. A look into your /etc/printcap should help. Following line is located in the Makefile

DEVICE= ’“/dev/lp0“’

Here you have to overwrite /dev/lp0 with the device you have to use. It’s also possible to put an filename instead the device into it. The so specified device or file is used as default. But it is possible to set another output with the options described in 5. Then all commands will be redirected into this file. You have to put the path you want install HPTools, into the line containing

HPPATH= /usr/bin

and the path of your manpages into the line

MANPATH = /usr/man

Now we can start compiling. Type make all

in the directory containing Makefile and hp.c. If you succeed, you first should test the executable in the local directory. Only type hpset which should resolve in a list of available commands. If everything works fine type

make install

After this procedure you will find the executable in the directory you defined. You will find the descriptions of the commands in section 6. If you have problems compiling or installing HPTools send a note with an error description to the address given in section 11. The compilation on other systems is not tested yet, but HPTools should compile on every ANSI-C compiler successfully, but you have to change the system specific parts. One of them is the device of the printer. If anyone managed it to compile HPTools on another system, I would like to get a copy of the Makefile and the changes, to put it into the next version of HPTools.

4 Usage

The usage of HPTools is simple. Just type the name of the executable, normally hpset, followed by the printer commands described later.

hpset [options] [Command1] [Command2] …

Notice that some commands need to be typed in a given order to work. This is described in section 6. On the first usage it is useful to check the function of the program. This is done by typing hpset test. This should start the printers self test.

5 Options

-h  Prints a help message.
-c  Writes the output into stdout which is similar to -o stdout
-o [file or device] Writes the output into the specified file or device.

6 Commands

6.1 Printer Steering

back  Puts every setting back to the printer defaults.
test  Starts the self test. Note, that this is the self test of the printer.
out  If paper is inside the printer, it will be thrown out.

cr After this command the linefeed is activated. So the printer is putting back the printerhead to the begining of the paper after every line. This is needed on LINUX, because of the standard ASCII which do not know MSDOS formating characters.

lbon  This command is activating the linebreak, to break too long lines.
leftright Forces the printer to print only from left to right.
rightleft Forces the printer to print only from right to left.
bidirect Forces the printer to print from left to right and from right to left.
execoff Every following command is not executed, but printed.
execon Every following command is executed.
nice  Enables high quality printing.
econo  Enables fast and economic printing. (Of course low quality).

6.2 Page Steering

landscape Prints in landscape format
portrait  Prints in portrait format
lpi#  Sets the lines per inch. For # type 6 or 8

6.3 Types

The following commands must be sent in the given order. If you don’t notice this, the printer may result in trash. The sequence has to look like:

hpset [characterset] [characterdistance] [character density] [point size] [type position] [line strength] [type]

Characterset  english ISO 4
ansi  ANSI ASCII ISO 6
sweden ISO 10
italian ISO 15
spain  ISO 17
german ISO 21
france ISO 69
Characterdistance prop  Proportional
fix  Fixed

If you’ve choosen proportional you dont have to set the character density.

Character density cpi#  # is one of 5,6,10,12,16,16.67,20,24
Point size  point# # is one of 4.75,5,6,7,8,9.5,10,12,14,19,24
Type position italic Italic
upright Normal
Line strength bold Bold
normal Normal
Type  courier Courier
times  CG Times
gothic Letter Gothic
univers Univers

Notice that not every combination of the commands above is possible. The following table gives an overview of the ones allowed.^{1}

Type  Direction Character Density Point Size Position Point Strength
courier portrait 5,10,16.67,20 6,12 upright normal

bold

courier portrait 5,10,20 6,12 italic normal

bold

courier landscape 10,16.67,10 6,12,24 upright normal

bold

times portrait  prop  5,6,7,8  upright normal
10,12,14  italic  bold
gothic portrait  6,12,24  6,12  upright normal
italic  bold
gothic landscape 12,24 6,12,24 upright normal

bold

gothic landscape 16.67  4.75,9.5,19 upright normal

bold

univers portrait prop 5,6,7,8 upright normal
10,12,14  bold
univers portrait prop 5,6,10,12 italic normal

bold

7 Using special printers

If you plan to use hpset with a remote printer for example, you have to redirect the output to the stdout. Now you can use a pipe to redirect this into a printermanager like lpr. For example you want to send commands to a remote printer called rhp. Then you have to use following command:

hpset -c [commands] |lpr -Prhp -l

or

hpset -o stdout [commands] |lpr -Prhp -l

1From the german manual of the HP560C

8 Usage with filters in printcap

By using lpr you might want to use other fonts or special settings. To get this permanently you can define a filter in printcap. The entry you need is if=/etc/text-filter where /etc/text-filter is a script with the printer commands. But first an example of the configuration for a printer with filter in printcap :

lp:lp=/dev/lp1:sd=/usr/spool/lp1:if=/etc/text-filter:sh

More information about the entries in printcap can be found in the manual page of printcap .^{2} The text-file script could look as follows:

#! /bin/bash hpset -o stdout out back cr lbon portrait zcat -f hpset -o stdout out

To mind is that you have to force hpset to write into the stdout . This is done by the -o stdout or -c option. Using zcat instead of cat make it possible to print zipped files.

9 Using the prompt function

If you execute hpset without any commands, the cursor will jump into the next line and will wait for input. It is also allowed to give some options but no commands to get in this mode. Now you can type in all available commands. A typical command sequence should be:

bytekiller: $ hpset hpset>execoff sending execoff command to /dev/lp1 hpset>landscape sending landscape command to /dev/lp1 hpset>execon sending execon command to /dev/lp1 hpset>out sending out command to /dev/lp1 hpset>quit bytekiller: $

This will print the ESC sequence of the landscape command and throw out the paper. The quit or exit command leaves the prompt. The help message is shown by typing help .

2called by man printcap

10 Next Versions

In the next versions I will try to get the printer command set out of the program, into a configuration file. So it should be possible to use the program with other printers only by changing the config-file. Also printer extension cards will be easy to handle. If this happens I will change the name of HPTools, because it is not longer bound on the HP printers. Which name I will use is not decided yet, but there will be a last HPTools version with the information you need to get the new one.

11 Errors

If there are any errors in the program or in the documentation, I would be happy getting an error report. If you’re not able to send email you also can use snail mail.

EMail: michael.janson@stud.uni-karlsruhe.de

Michael Janson Ostmarkstr.19 76227 Karlsruhe Germany

12 Thanks

Special thanks to Stephan Fuhrmann (stephan.fuhrmann@stud.uni-karlsruhe.de) and Claudio Matsuoka (clauio@brasil.enemy.org) for testing this program and giving me a helping hand in some programming questions.