Subject: configuring PS Printers
To: None <port-mac68k@NetBSD.ORG>
From: Steve Hawley <hawley@mv.us.adobe.com>
List: port-mac68k
Date: 02/05/1996 13:26:08
Lesson time!  Gather 'round!  This is all from memory, so caveat emptor.

OK, let's assume that your printer is a Level 2 PostScript printer.

As such, it has a pretty flexible mechanism for IO configuration.
Remember that LocalTalk is really just an RS 422 implementation of
AppleTalk and that means that if your printer has a LocalTalk port,
it also has a Serial port that can do RS 232 too.

executing currentsystemparams will return a dictionary of key/value
pairs that list what features are currently active in your printer.
Two important keys are /CurInputDevice and /CurOutputDevice.  These
devices are opened for reading and hooked up to the streams %stdin%,
%stdout% and %stderr% when the printer starts its job server loop.

On your printer, these values are most likely set to (%LocalTalk%).
You want to change this.

Most PS printers have a device called (%Serial%) which is a plain
serial device.  So you can set this with something like this:
<<      /Password 0
        /CurInputDevice (%Serial%)
        /CurOutputDevice (%Serial%)
>> setsystemparams

Now this may not be what you want because (%Serial%) may not be configured
correctly, so you need to do something like this first:

(%Serial%) <<
        /StopBits 1
        /Enabled true
        /Baud 9600
        /CheckParity false
        /Parity /None
        /On True
        /FlowControl /XonXoff
        /Interpreter /PostScript
        /DataBits 8
        /Protocol /Normal
>> setdevparams

Now if you do both of these, the new parameters should take effect at the
end of this job.  Unfortunately, this is still not quite what you want
because you would like these changes to be permanent, right (actually,
not at first because if you screw up you want to be able to get back to
a known state)?

so you need to exit the job server:

serverdict begin 0 exitserver

follow this with the config for the (%Serial%) port if you need it,
followed by the setsystemparams code.  Save it in a text file.

>From MacOS, you can send this file to the printer with Drop*PS which
you can find at the info-mac archives.

but FIRST what you really want to do is see how your printer is set up,
so send the following PostScript program to the printer:

%!

% This snippet of code worms its way into your printer and dumps out all
% the information it can find about the system parameters and all available
% IO devices.
% 2/96 Steve Hawley hawley@adobe.com
% This is NOT official Adobe sanctioned code.

/fontsize 9 def
/leading 2 def
/y 725 def
/nl {
        /y y fontsize leading add sub def
        y 24 lt { showpage /y 725 def } if
        24 y moveto
} def
/dictlevel 0 def
/scratch 1024 string def

nl

/Courier findfont fontsize scalefont setfont

/dicttab {
        dictlevel 4 (W) stringwidth pop mul mul 0 rmoveto
} def

/dumpdict {
        (<<) show nl
        /dictlevel dictlevel 1 add def

        { exch dicttab (/) show scratch cvs show 4 (W) stringwidth pop mul
0 rmoveto
                dup type dumpstuff exch get exec } forall

        /dictlevel dictlevel 1 sub def
        dicttab (>>) show nl
} def

/dumparray {
        dup xcheck { (}) ({) } { (]) ([) } ifelse
        show nl
        exch
        /dictlevel dictlevel 1 add def
        { dicttab dup type dumpstuff exch get exec } forall
        /dictlevel dictlevel 1 sub def
        dicttab show nl
} def

/dumpstuff <<
        /arraytype  { dumparray }
        /booleantype { {(True)}{(False)}ifelse show nl }
        /conditiontype { (--conditiontype--) show nl }
        /dictttype  { dumpdict }
        /filetype { (--file--) show nl }
        /fonttype { (--font--) show nl }
        /gstatetype { (--gstate--) show nl }
        /integertype { scratch cvs show nl }
        /locktype { (--lock--) show nl }
        /marktype { (--mark--) show nl }
        /nametype { (/) show scratch cvs show nl }
        /nulltype { (--null--) show nl }
        /operatortype { (--operator--) show nl }
        /packedarraytype { dumparray }
        /realtype { scratch cvs show nl }
        /savetype { (--save--) show nl }
        /stringtype { (\() show show (\)) show nl }
        >> def

/dumpresource {
        dup show 4 (W) stringwidth pop mul 0 rmoveto
        /dictlevel 0 def dicttab
        currentdevparams dumpdict
} def

(Current system paramters:) show nl
currentsystemparams dumpdict
(Dump of all devices:) show nl
(*) { dumpresource } 1024 string /IODevice resourceforall

showpage
%%EOF

This will print out several pages with all your system params, their
values and all your devices.

You will notice some devices like:
(%Serial_Pending%) and (%Serial_NV%)
Don't write to these unless you REALLY know what you're doing.
(%Serial_Pending%) will contain all the changes you make to (%Serial%)
that will take effect after this job is over.  (%Serial_NV%) are the
parameters that are stored in Non-Volatile memory.

Be aware too that your printer may not have non-volatile memory and you
must actually set the values via DIP switches.  Most printers have NVRAM.

Here endeth the lesson.  :')

Steve Hawley
hawley@adobe.com
--
"It's too bad that whole families have to be torn apart by something as
simple as wild dogs."  -- Deep Thoughts, by Jack Handey