So you install the latest OS and your printer becomes obsolete?

System: Power Macintosh G3
Printer: Color Stylewriter 2400
Connection: printer port

Everything works great under MacOS 9 you can share the printer out over the network so all mac's can us it. Other than the printer is a little old and slow the printer works great.

Then you switch to MacOS X and nothing works for the printer no support, no clues, no obvious information about how to get printing again. All the documentation simply says that only USB printers are supported. So whats the good news? Well this is now a unix box so if there is a will there probably already is a way. So first step is make sure the serial port does actually exist and can be talked to. Simple enough search around /dev and you find /dev/cu.printer and /dev/cu.modem looks like serial ports are supported.

Now we need a way to try and talk to the printer. Quick jump on the internet searching for anyone that has put together support for a Color Stylewriter 2400 on unix and what turns up is Non-MacOS StyleWriter driver looks like a great start download take a look try a simple compile:
cc -Dunix -o lpstyl lpstyl.c
seems like a clean compile now for a test.

To test it we need ghostscript go to Apple download the latest and install very simple even nicely packaged and everything. To bad I don't like the way they install these packages but thats another story what they have works good enough to get something working.

Once ghostscript is installed you can try a simple test to see if you can talk to your printer:
enscript --output=- /etc/hosts | gs -q -dBATCH -dPARANOIDSAFER -dQUIET -dNOPAUSE -sDEVICE=pbmraw -r360x360 -sOutputFile=- - | lpstyl -f /dev/cu.printer
if all goes well you should have a copy of your /etc/hosts file printed to your printer.

So now we know the serial ports do work and software exists for correctly talking to the StyleWriter printer that can be used on MacOS X. So now the question is how do we get the MacOS X printing system to use it? You might start by reading all the Apple developers stuff on printing and all the other documentation Apple has however you quickly find there is not much of real value there. You can see from the information there the printing systems seems very modular and just adding in this piece should be fairly simple. However none of the documentation has the details really required. But, after a little investigation you will discover MacOS X is simply using Common UNIX Printing System (CUPS). Reading the literature availalbe for CUPS almost all the details required to understand how to modify Apples printing system can be found. CUPS although not simple has a lot of functionality that Apple doesn't talk about. As of writing this the current version of CUPS is 1.1.18 the version that appears to be in MacOS X (10.2.3) is 1.1.15. Experimenting with the version on MacOS X vs what is documented at the CUPS web site you will find that the MacOS X version seems to have removed all serial port support. However it looks like perhaps it may show up in some later release because the serial backend in CUPS 1.1.18 has mod's to it to properly identify all the serial ports on MacOS X from revision logs it looks like this first appeared in 1.1.17 of CUPS. So perhaps there is hope for the future.

However I'm interested in fixing things for what is in MacOS X. Since I need access to the serial ports the first thing I did is take the backend serial support that works in 1.1.18 and added it to MacOS X this was simply a matter of downloading the latest version of CUPS building it as described in that documentation then taking the serial excutable from the source backend directory and adding it to /usr/libexec/cups/backend once their if you restart the Printing service (Don't get me started on Apples unique way of starting and stopping services) you can now see that CUPS does report the existing serial ports:
lpinfo -v
If lpinfo -v does not show any serial devices try:
/usr/libexec/cups/backend/serial
and make sure it produces output like:
serial serial "Unknown" "Serial Printer (serial)"
serial serial:/dev/cu.modem?baud=115200 "Unknown" "modem"
serial serial:/dev/cu.printer?baud=115200 "Unknown" "printer"
If it does not something is wrong with your serial backend. Probably you need to recompile it on this system.

Now the question is how to get CUPS to use the lpstyl software to print. The answer for this can be found at Linux Printing.org. This turns into a small adventure in it self but the two key things is first we need a PPD file for the Color StyleWriter 2400 which that website can produce and second we need to get cupsomatic installed and working.

I down loaded the cupsomatic file and copied it to /usr/libexec/cups/filter ran it by hand to make sure it was finding perl and was runable since I expected problems initially I also set the line "my $debug=0;" to "my $debug=1" this produces output in /tmp of the most recent run results. The PPD file I down loaded expected other unix style device names. The fastest way I found to fix it was to add -f /dev/cu.printer to each line with lpstyl it probably would be little better to correct the DEVICE section of the PPD file. Then I copied the ppd file to /usr/share/cups/model. Then created a printer:
lpadmin -p stylewriter -m <printer ppd file>.ppd -v serial:/dev/cu.printer -E

So with a little adjustment here and there plus a few extra stopping and starting of the cupsd the produced PPD file can be made to work. The cupsomatic perl script in the end did not require any modifications.

So after that long adventure I now have a working Color StyleWriter 2400 printer hooked up to my Power Macintosh G3 printer port and all MacOS X software prints to it cleanly from the GUI's or from the command line. As an added bonus I also have the laserwriter driver installed on all my other mac's configured so that they send print jobs over to the queue on that machine. I find it actually works far better than the MacOS 9 drivers ever did in system performance and printer through put.

For those interested I was able to get my stylewriter working for other computers on the network as follows. First I added the following line to /etc/inetd.conf:

printer stream tcp nowait root /usr/libexec/tcpd /usr/libexec/cups/daemon/cups-lpd -o document-format=application/octet-stream

This method uses tcp-wrappers so you can provide a little extra security so that not just anyone can user your printer. To then define which printers can send print requests you have to add something like the following to /etc/hosts.allow:

cups-lpd: .jenika.com

Then it is also good to edit /etc/hosts.deny and add:

ALL: ALL

With that in place you can now accept remote print requests. For MacOS 9 or older use the DeskTop Printer Utility to create a new laserwriter printer that can send to your print server.

Window: New Desktop Printer
Select: LaserWriter 8
Select: Printer (LPR)
Click OK

At the next window:

Window: Untitled1
PostScript Printer Description (PPD) File (Leave as generic you only get Black and White change to a generic color laserprinter you can get color)
LPR Printer Selection (Click Change enter address of your server either DNS name or IP Address then enter the printer queue name it would be "stylewriter" if you used the command in this write up for creating the queue)
Click Create

For MacOS X remote printer support first go to System Preferences-Sharing and enable Printer Sharing. Then from any other MacOS X add a new printer of type IP Printing you should see the printer listed. I don't encourage this adventure for the non technical folks out there but I thought it was interesting that with a little effort (~8 hours) it can be done.

Matthew McGillis
Jenika Inc.