🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #16

Re: Sending special characters to serial connected LaserWriter

#16
From: Scott Winders
Date: Wed, 28 Oct 1992 00:50
168 lines
9072 bytes
In article <1992Oct27.035357.4293@adobe.com>, delahunt@adobe.com (Jim
DeLaHunt) wrote:
> 
> In article <1992Oct26.202733.5318@island.COM> hue@coney.island.COM (Pond 
> Scum) writes:
> >I would like to be able to print files which
> >contain binary data to a serially attached PostScript printer, but I
> >cannot figure out how to send down the special characters (^A, ^C, ^D,
> >^Q, ^S, ^T, and ^[) without them being interpreted as the special
> >characters.  I have a document titled "Adobe Serial and Parallel
> >Communications Protocols Specification" and it says there is no way
> >to send these characters to the printer if the printer only supports
> >the standard protocol.  [and the NTX supports only the standard protocol]....
> >I figure there must be a way to get this to work because I don't
> >hear people complaining about not being able to print their Mac
> >PostScript files via CAP because they contain binary data.  ....
> 
> The rules for data protocols on AppleTalk connections to PostScript printers
> are much simpler:  there is one protocol, it doesn't reserve any special
> characters, you can send full 8-bit binary data, and all job control functions
> (e.g. marking end-of-job) are out-of-band.
> 
> On RS232 and Centronics connections, PostScript printers reserve certain
> bytes values for job control functions (e.g. ^D means "end of job").  This
> is the Adobe Standard Protocol.  Some printers support other protocols, 
> such as BCP and TBCP, which provide a way to escape the special byte values
> and use them as data.  The tech note you have describes these other protocols.
> 
> The upshot is: the data protocol you use, and the kind of data you can send,
> depends on the communications channel.  On RS232 and Centronics connections,
> you sometimes can't send arbitrary binary data.  On AppleTalk connections,
> you almost always can.
> 
> >Thanks,
> >Jonathan		hue@island.COM
> 
> Followups to comp.lang.postscript.
> 	--Jim DeLaHunt, Developer Support, Adobe Systems Incorporated	
> delahunt@adobe.com	...!{apple,decwrl}!adobe!delahunt      +1-415-962-3790

The LaserWriter IIf/IIg and Personal LaserWriter NTR offer three different
serial protocols: Raw, Normal, and Binary. There are configurable using
the LaserWriter Utility that comes with the printers.

Here are the definitions:

Raw: Lets all data pass through unfiltered. Control characters such as 
End-of-file (CTRL-D) and status queries (CTRL-T) or passed through and not
acted upon.

Normal: Data passing through is filtered. Control characters perform their
intended function. Status queries (CTRL-T) will have a status returned;
End-of-file (CTRL-D) characters will end print job.

Binary: We took the following from pages 15 to 17 of the "LaserWriter IIf
and LaserWriter IIg Printers Developer Note" (APDA R0230LL/A):

Binary serial protocol

LaserWriter printers support an alternate protocol for the serial
communication channels. While this protocol allows all character codes to
be transmitted as data, it also allows certain characters to be used for
specifying control functions, which may be handled asynchronously by the
communications driver. Those control functions include requesting status,
aborting a job, marking ends of jobs, and controlling flow for the serial
channels.

Because this protocol can transmit any character code, it can be used for
sending PostScript language jobs that contain binary images or for sending
commands with any sequence of control characters to emulators.

Because this protocol can be used for sending both PostScript language
programs and emulation jobs, it provides a way of switching between the
PostScript interpreter and the emulators without flushing the input
buffers.
The manner of switching between PostScript language programs and emulations
is described in Chapter 3 of the "LaserWriter Reference".

To select the binary serial protocol, set the operating mode switch to
position 6, or use the LaserWriter Utility to set one of the changeable
parameter sets to use binary protocol.

The binary serial protocol requires the host computer to insert a quoting
character at certain places in the data stream and to modify the character
codes for certain characters. (This procedure is described later in this
section.) That means that the host computer must filter the data before
sending it to the printer. The filtering may be done by an application
program or within the operating system of the host computer.

When the binary serial protocol is enabled, it operates on communications
in both directions. Therefore, the host computer must also filter any data
it receives from the printer.

There are eight control characters that are treated as control functions
rather than as data when they are received by the communications driver.
The control characters are defined in Table 2-1.

Table 2-1  Control characters in the binary serial protocol

Hex value    ASCII name    ASCII function    Control function

01           SOH           CTL-A             Quote data byte
03           ETX           CTL-C             Abort job and flush to eof
04           EOT           CTL-D             End-of-job marker
05           ENQ           CTL-E             None
11           DC1           CTL-Q             XON in XON/XOFF flow control
13           DC3           CTL-S             XOFF in XON/XOFF flow control
14           DC4           CTL-T             Request printer status
1C           FS            CTL-\             None

To transmit these characters as data, they must be quoted, as follows. To
quote a character, the program replaces the character with the
two-character
sequence consisting of CTL-A followed by the result of the exclusive-OR
(XOR)
of the character to be transmitted with $40 (the dollar sign indicates
hexadecimal). For example, to send a byte with the value $14, a program
must
send the 2-byte sequence $01$54. This method of quoting guarantees that
whenever any of the eight special characters is received, the control
function is intended, regardless of whether the preceding character is a
CTL-A. Because of that character independence, the generation and
processing
of asynchronous control characters can take place at a lower level than the
generation and consumption of the data stream. In particular, on the host
computer, the CTL-A quoting convention can be implemented by a user program
while XON/XOFF processing is performed independently by the operating
system.

All byte values other than those of the eight special characters are
transmitted by simply sending the value.

After a CTL-A is received, the next character received that is not one of
the eight special characters must be the result of XORing one of the
special
characters with S40. The reception of any other character constitutes an
error in the input data. Between the CTL-A and the XORed character, any
number of special characters may appear, except for the special characters
that are handled synchronouslyQCTL-A and CTL-D. Reception of CTL-A or CTL-D
between a CTL-A and the XORed character constitutes an error.

When one of the special characters arrives unquoted and it specifies no
control function for the channel, the character is discarded. For example,
if XON or XOFF is received and XON/XOFF flow control is not in use, the XON
or XOFF character is discarded. The characters CTL-E and CTL-\ currently do
not specify any control functions. They are included among the characters
that must be quoted
future.

The binary serial protocol is different from the simple serial protocol in
that there is no mapping between end-of-line conventions with the binary
protocol. Whatever end-of-line character (<CR>, <LF>, or <CR><LF>) is sent
by the host is received by the interpreter or emulator in the printer. The
PostScript interpreter handles different end-of-line characters in a
uniform
way, but a program that reads data (by means of a read or readstring
operator) receives whatever characters were sent by the host. Likewise,
whatever output is generated by a PostScript program (by means of a print
or = operator) is sent unchanged.

Note: The standard end-of-line character in the PostScript language,
corresponding to '\n' in a PostScript language string, is <LF>.


Scott Winders
winders@aux.support.apple.com

"My opinions are my own, not my employer's"
Technical Details
Message-ID: <winders-271092164502@macwinders.support.apple.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!data.nas.nasa.gov!taligent!apple!macwinders.support.apple.com!user
References: <1992Oct26.202733.5318@island.COM> <1992Oct27.035357.4293@adobe.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!ames!data.nas.nasa.gov!taligent!apple!macwinders.support.apple.com!user
From: winders@aux.support.apple.com (Scott Winders)
Newsgroups: comp.lang.postscript
Subject: Re: Sending special characters to serial connected LaserWriter
Message-ID: <winders-271092164502@macwinders.support.apple.com>
Date: 28 Oct 92 00:50:29 GMT
References: <1992Oct26.202733.5318@island.COM> <1992Oct27.035357.4293@adobe.com>
Sender: daemon@Apple.COM
Followup-To: comp.lang.postscript
Organization: Apple Computer, Inc.
Lines: 168