To: ISL
From: Glen Williams
Subject: "Cedar" Print Server
Date: January 5, 1982
Stinger is able to run as an ersatz Interpress server. This means that you can print images from Cedar graphics on it. In order to make a print, you must get the right program running on Stinger then send it the image using routines discussed below.


Starting the Server

The program to run on Stinger is Mesapress. To run it, swat out of EFTP if it’s running, and type a control-C to prevent Press from printing. Then type the two words "Mesapress server" to the exec. [Sometimes, the Alto will go south -- meaning the microcode is completely botched. This is because of a bug in EFTP. If this happens, boot the machine twice and continue. Incidentally, you can boot after swatting out of EFTP to avoid this possibility.]

At this point the server is waiting for a connection.

Necessary Software

In order to send an image to Stinger, you will need two bcd’s that live on [IVY]<GWilliams>Pilot>Mesapress>Bcds> (sources are on [IVY] <GWilliams>Pilot>Mesapress> Sources>). The first is the defs file, PressNetDefs.bcd, the second, PressNetSender.bcd. There are some rudimentary instructions in the Defs file. It’s a good idea to have a copy of PressNetDefs in hand to scrutinize the data types etc.

Currently the sender is allowed to send one page only. The steps in sending a page to the printer are the following.
Call GetPrinterAttributes to determine scan-line direction of desired printer [Stinger].
Call PrinterReady to see if the printer is available.
Call SendPageAttributes to let the printer set up its parameters.
Call SendLine lastScan-firstScan+1 times to transmit the scan lines.
Call CloseConnection.

Determining Printer Attributes

GetPrinterAttributes
returns an object that has information you’ll need in scan conversion. scanDirection determines how the printer lays down bits: across the page if portrait mode, or up the page lengthwise if landscape mode. resolutionB is the bits/inch in the scan line while resolutionS is the scanlines/inch. scanLengthInches is the maximum length of the scan on this printer.

Connecting to Printer

Call PrinterReady when you want to connect to the server. It will try to connect to the server, and retry the number of times you specify in the call. This retry count is a course timeout parameter in which each count is ~10 seconds. PrinterReady will return FALSE if the server is either busy with another client, or doesn’t answer at all. It will signal with an error -- PressSendError if anything else goes wrong. PressSendError is usually a renamed EFTP error. A return of TRUE implies that you have the server.

Server Initialization

Once you have the printer, you need to send it information as what to do with future data packets. This is done using routine SendPageAttributes which takes a PageAttributes record as an argument. This record consists of 4 values. firstScan is the "address" you want your first scan line to appear on the page. For instance, on a landscape machine of 384 scans/inch, a firstScan value of 576 will put the first scan line 1.5" from the left edge of the page. lastScan is simply firstScan plus the number of scan lines you’re sending. margin is the number of bits into the page to position the beginning of the scan; on a landscape machine, this determines the bottom margin. bitWc is the count of 16-bit words in the scan line. If PressSendError is raised, there was trouble with the parameters and the connection is closed.

Setting Timeout Parameter

SetRetries
is a procedure you can call at any time to set the timeout value to be used when sending data to the server. This need only be used to change from the default value of one.

Sending the Data

SendLine
sends a scan-line of bits to the printer. The number of words sent is taken from PageAttributes.bitWc. It can raise PressSendError under exceptional circumstances, or if it times out while trying to send data. If this error is raised, the connection to the printer is closed, so don’t worry about closing the connection in this case.

Closing the Connection

After you’ve sent the last scan-line of data, call CloseConnection. Don’t forget to call it as no other client can connect to the server other wise.
A Note on PressSendError
This error is raised under a number of exceptional conditions. There is a variable associated with it, err, that can be discriminated to find the exact condition. There is also a string, s, which, if not nil, gives a description of the problem as well.