Would you like to make this site your homepage? It's fast and easy...
Yes, Please make this my home page!
Printing to an HP Printer from your Sparc
I get a lot of benefits out of the newsgroup "comp.sys.sun.admin"
from people who post solutions and suggestions to my problems. When
I ultimately get something working as a result, I feel obligated to
give something back. The solutions here are a combination of some posts,
some responses, and some of my own testing and experimentation.
Feel free to use this information as you see fit. All I ask is to
reference this work where appropriate and send me email to let me know
if any of this was useful to you.
Include the standard disclaimer here, Copyright Jeff Goldman 1997.
Updated 1/17/96.
SUMMARY
This page goes into the details of getting an HP DeskJet+ printing ascii
and postscript on a sparc running Solaris 2.5. For SunOS 4.1.x, please
read this page.
I had some problems with the serial hook up for Solaris 2.5. It had
appeared to work properly when I originally posted these pages.
You can read about the problems here.
I still left the instructions about the serial hook up, but be prepared
for trouble.
However, I did finally get the parallel solution working with some
help from MAGMA because I have
a magma board for my parallel interface (and the interface was the
problem). If someone does solve the serial problem, I would like
to hear from you.
With minimal modification (I hope), these instructions should work for
the family of printers supported by ghostscript. If you already have
a postscript printer that is supported by Solaris "point and click"
admintool selecting, you are lucky and don't need to read this.
If you have any questions, comments, useful modifications to this page,
suggestions, or other steps that worked for you, feel free to send me email.
For additional help with terminals, modems, ports, and printers(?), see
Celeste's web page.
Sincerely,
Jeffrey Goldman
goldman@ucla.edu
Home Page: http://www.cs.ucla.edu/~goldman
TOOLS
- Solaris 2.5 (2.4?)
- A printer that you hope to have working with Solaris
- A null modem cable or a standard PC parallel printer cable
- ghostscript version 3 or later (I used 4.02)
ASCII printing
- 1) Connect the HP DeskJet+ to your Sparc using a Null Modem Cable to the
serial port of your choice.
I also had success connecting the printer to the parallel port using
a standard PC printer cable DB25 to Centronics36.
- 2) Using the "admintool" in Solaris 2.5, select the Serial Ports menu
under "Browse" and set the serial port you are using to
"Initialize Only - No Connection", check "service enable", and set the
baud rate. I set mine to 19200 because the maximum speed on the DeskJet
is 20,000bps.
If you are connecting via parallel, there is nothing to do in this step.
- 3) Next in the admintool, go to printers under "Browse" and add a local
printer. Give the printer a name (say "deskjet") and set the port to
/dev/term/a for serial or the appropriate device name for parallel.
With my MAGMA board, it is /dev/pm00. The printer type should be set
to "HP Printer" in the menu. Finally, set the contents to ASCII.
- You now have an HP DeskJet+ capable of printing ASCII files. If you wish
to turn off the banner page (like me), edit the file
"/etc/lp/interfaces/printer_name" (our example was printer_name="deskjet")
so that line 332 reads: nobanner="yes".
...
nobanner="no" --> nobanner="yes"
nofilebreak="no"
stty=
...
Postscript printing
- 0) If you have already performed the steps in the ASCII printing section,
continue to step 1, otherwise if the printer isn't connected to the
computer, see step "1" in the previous section. If you are connecting
to the serial port, perform step "2" in the previous section.
NOTE: as said earlier, I could not get postscript printing to work properly
with the serial interface. You can read about the
problems here. These problems did
not show up right away so I apologize for posting my solution
early. With the serial interface, you are on your own...
- 1) With the admintool, add a new printer (we will call it "djs" for deskjet-
serial). Set the port to /dev/term/a (or b) for serial and set the
contents to "Postscript" (the printer type should be set to "HP Printer").
For the parallel solution, add a new printer ("djp") and set the port
to /dev/pm00 (or whatever your machine's appropriate parallel port is).
The contents should be set to "Any" (the printer type should be set
to "HP Printer").
- 2) Replace the file "/etc/lp/interfaces/printer_name"
with the file found here. A special thanks
to Joseph F. Kabara who gave me a script that he uses for his set up
with Solaris 2.5 x86.
For the parallel solution, replace the file "/etc/lp/interfaces/printer_name"
with the file found here.
This interface simply changes the following lines from the Solaris 2.5
generated interface file:
- change line 334
- from:
- stty=
- to:
- stty="-opost"
- add the line (after "badfileyet=" - line 919)
- stty ${stty} 0<&1 1>/dev/null 2>&5
- optional:
- change line 332 (to surpress banners)
- from:
- nobanner="no"
- to:
- nobanner="yes"
You may need to set dip switches on the printer (consult your manual).
I needed to set the carriage return definition to "CR only". Handshaking,
baud rate and parity shouldn't matter for a parallel connection.
For the parallel solution, I also use this small
script. Naming the script "postprint"
allows you to use the command "postprint anyfile.ps" to send the file
to ghostscript where it is converted to PCL and then passed the printer.
I know it is a hack but I didn't alter the printer interface file
to do the conversion. It is probably easy to do. If someone is willing
to fix the interface file, I would be happy to post it!
- This new interface file sends the postscript output through ghostscript
and converts it to HP PCL for printing. If you have another printer,
it should be possible to change the one or two lines to the appropriate
ghostscript filter. Just use your favorite editor and search for
"deskjet" and change it to your printer (relevant files: interface.txt or
postprint).
Comments
For the serial setup,
I like the setup with two printer entries. I can send postscript and ascii
to "djs" or I can send ascii to "deskjet". The ascii on "djs" is slow but
the output is a little nicer. For the quick drafts, I can use "deskjet".
Just be careful with sending lots of stuff to both queues. Data will
probably get lost. You can fix this by using the enable/disable command.
(see the man pages on this)
For the parallel setup, you actually only need a single entry (a
single printer). With the postscript printer instructions, you can
send ascii files to the printer directly (without the "postprint")
with the lp command.
Problems
- For ASCII printing, there were very few problems. With a parallel
connection,
I just needed to make sure the port was "disabled" in the serial ports
menu for the admintool. With the serial connection, the trick was to set
the serial port to "Initialize Only"
- For postscript printing, there were lots of problems...
- For the serial connection...
If you have problems printing the postscript such as extra junk
in the margins and/or lots of extra form feeds in the middle of
the document, you need to modify the ghostscript software.
On the ghostscript
home page, there is
a section that discusses a patch for the older DeskJet printers.
The patch is already in gs4.02 but it didn't work, at least not
for me. The optional suggestion that did work, and that I sent
to ghostscript in a bug report back with gs3.51 is that the HP DJ+
can't seem to perform the compression correctly. I changed it
from "mode_2" to "mode_0". In the comments, they use "mode_2"
but "mode_2" is HP PCL level 4. The HP DeskJet manual says
it can only perform HP PCL level 3.
Here are the changes for gs4.02 in
file gdevdjet.c:
- 276c276
- new /* The DeskJet can compress (mode 2) no it can't! not for serial! */
- ---
- old /* The DeskJet can compress (mode 2) */
- 279,280c279,280
- new { return hpjet_print_page(pdev, prn_stream, DJ, 300, mode_0,
- new "\033*b0M");
- ---
- old { return hpjet_print_page(pdev, prn_stream, DJ, 300, mode_2,
- old "\033&k1W\033*b2M");
To read about this in detail, see
the ghostscript
ghostscript home page. The above will get rid of the problem.
- For the parallel connection...
The problem turned out to be one with "-opost". This could be
specific to the magma board but the solution was that modification
with the stty in the interface file. Furthermore, I tested
ghostscript 4.02 without changing the gdevdjet.c file
(leaving it mode_2), and it worked! Maybe for some reason
compression works for parallel and not serial, but I doubt it.
More likely, my serial instructions have an error or two.
It may also be the case that there is some strangeness going
on with the mode compression. When I was using SunOS 4.1.x and
the new version came out with the mode_2 compression, my solution
stopped working. It was only corrected by changing it back
to mode_0.
Finally, even with all of this effort, the files still print
with a blank page in between all of the pages. In other words,
it prints page 1, form feeds a blank page, prints page 2, form
feeds a blank page, etc. I don't know why. It happened using
gs4.02 and gs2.62 (the version of gs before lots of changes
to the deskjet methods).
After playing
with the form feeds in the interface file, the problem persisted.
Any insights would be greatly appreciated.
To help us all, please send me email (goldman@ucla.edu)
of your experiences using any of these
files. Thank you.