[comp.lang.postscript] 9600 bps bottleneck on Laserwriter Plus

jim@cavevax.ucsb.edu (Oreo Cat) (01/09/90)

Hello all you postscript hacks out there!  I have a quick question for
you.  We have an Apple Laserwriter Plus here in our lab.  Occaisonally
we have to print out large bitmapped images.  Since our printer is 
hooked up to a serial line, it is limited to 9600 bps.  Since bitmaps
are inherently large, it takes a long time just to get the image into
the printer.  I have timed it, and it takes just slightly more than
the time to I computed it to take just to get across the line.  I figure
with handshaking, and all the other miscellaneous delays, that it doesn't
take the printer any time at all to figure out how to print the thing,
it's just waiting for the data to all get there.  Some of these images
take quite a long time to print out.  Since we only have one printer, and
it is used daily by 4-5 people, having the printer essentially unavailable
for 30 minutes to an hour at a time is a great inconvenience.  And if
multiple images need to be printed out, other people can sometimes get
upset.  The serial port on the host computer can be driven at up to
38400 bps, but unfortunatley the serial port on the LW+ only goes up to
9600.  I am told that the appletalk connection runs at something like
64 kbps.  Is there any way of connecting this to a serial port?  Or is
there any way of making the serial port run faster than 9600?
  It now looks like we'll be printing more of the bitmaps, so any
cheap solutions to this problem would be greatly appreciated!

  Jim Lick
  jim@cavevax.ucsb.edu

amanda@mermaid.intercon.com (Amanda Walker) (01/10/90)

In article <3495@hub.UUCP>, jim@cavevax.ucsb.edu (Oreo Cat) writes:
> The serial port on the host computer can be driven at up to
> 38400 bps, but unfortunatley the serial port on the LW+ only goes up to
> 9600.  I am told that the appletalk connection runs at something like
> 64 kbps.

Well, it runs at about 240kbps in AppleTalk mode, but that isn't useful
in your situation unles your host understands AppleTalk network protocols.
The standard switch settings only let you ask for up to 9600 baud, but the
printer will operate faster.  It will receive data at up to 57600 baud,
or maintain reliable bidirectional communication at up to 19200 baud.
I haven't ever tried to run it at 38400, but there shouldn't be any problem.

The PostScript operators 'setsccbatch' and 'setsccinteractive' (described
in the LaserWriter supplement in the back of many editions of the Red Book)
control baud rates.  Here is some code that I believe should set your printer
to 38400 baud, but since I run over AppleTalk exclusively, I haven't
tested it--Woody will probably set me straight if I've made a goof here
:-):

	statusdict begin
	25 38400 0 setsccbatch
	end

This should change the '9600' switch setting to actually select 38400 baud.
The baud rate is actually changed at the end of the current job, and should
be persistent across power cycles unless a stray lightning bolt zaps the
EEPROM in your printer :-).

Hope this helps,

Amanda Walker
Speaker to PostScript
InterCon Systems Corporation
--

alex@grian.cps.altadena.ca.us (Alex Pournelle) (01/10/90)

jim@cavevax.ucsb.edu (Oreo Cat) writes:

>The serial port on the host computer can be driven at up to
>38400 bps, but unfortunatley the serial port on the LW+ only goes up to
>9600.  I am told that the appletalk connection runs at something like
>64 kbps.  Is there any way of connecting this to a serial port?  Or is
>there any way of making the serial port run faster than 9600?
>  It now looks like we'll be printing more of the bitmaps, so any
>cheap solutions to this problem would be greatly appreciated!

I'll throw out an answer I thought up some time ago, and never
implemented.  Like all ideas, it's free; if someone does it, I'd like a
copy!  Apologies if this has been "done before"; I'm new here.  If it
has, I'd certainly like to know about it, having a similar problem.

Implement a postscript decompresso program--one that "unsqueezes" data
as it comes through the pipe--download it to the printer, then do the
reverse on the computer.  With some simple escapes, you could massively
increase throughput on nearly any large file.

Naturally, you'll have to hand-assemble the code on the host machine, in
order to see a significant increase in throughput.  But even a 2 to 3x
compression should be achievable easily, in total wall clock time.

Comments?
	
		Alex

woody@rpp386.cactus.org (Woodrow Baker) (01/10/90)

In article <3495@hub.UUCP>, jim@cavevax.ucsb.edu (Oreo Cat) writes:
> you.  We have an Apple Laserwriter Plus here in our lab.  Occaisonally
> we have to print out large bitmapped images.  Since our printer is 
> hooked up to a serial line, it is limited to 9600 bps.  Since bitmaps
> 38400 bps, but unfortunatley the serial port on the LW+ only goes up to
> 9600.  I am told that the appletalk connection runs at something like
> 64 kbps.  Is there any way of connecting this to a serial port?  Or is
> there any way of making the serial port run faster than 9600?
Off hand, there are 2 possbilities.  The first is to get a larg printer buffer,
and the second involves changing the baud rate.  You can indeed set the
printers baud-rate to a higher value.  Don Lancaster runs his at 57Kbaud, over
the serial line, but it is unidirectional only.  I'd suggest that you could
set the baud-rate on the printer to 38.4k and try it.  you can always reset
it back.  Just use the command as it is documented in your suppliment, but
change 9600 to say 19200 or 38400 and try it.  Alternatly you can call Don
at 602-428-4073 and pick his brains.  He's fairly helpful.

Cheers
Woody
 
> 
>   Jim Lick
>   jim@cavevax.ucsb.edu

ericbi@microsoft.UUCP (Eric BIDSTRUP) (01/10/90)

In article <1990Jan10.042555.19571@grian.cps.altadena.ca.us>, alex@grian.cps.altadena.ca.us (Alex Pournelle) writes:
> 
> Implement a postscript decompresso program--one that "unsqueezes" data
> as it comes through the pipe--download it to the printer, then do the
> reverse on the computer.  With some simple escapes, you could massively
> increase throughput on nearly any large file.
> 
> Naturally, you'll have to hand-assemble the code on the host machine, in
> order to see a significant increase in throughput.  But even a 2 to 3x
> compression should be achievable easily, in total wall clock time.
> 
> Comments?
> 	
Sure...
As someone who has attempted to do this before, I recommend you
save yourself the time & energy.  What happened (in my case) was
that the decompression routine took longer to execute & translate
the data stream than simply sending the same data in a non-compressed
format.  I also remember seeing a thread here or on CIS about the
same idea a year ago w/ others having similiar results.  Now that
other printers in the marketplace (the newer HP PaintJet XL for
sure, and I think some of the newer LaserJets) provide commands
to accept bitmapped data in a number of compressed formats, we
can all hope that subsequent revisions of Postscript add commands
to do this to.
-Eric Bidstrup

Disclaimer: Opinions expressed are my own.

achille@cernvax.UUCP (achille petrilli) (01/11/90)

In article <1990Jan10.042555.19571@grian.cps.altadena.ca.us> alex@grian.cps.altadena.ca.us (Alex Pournelle) writes:
>jim@cavevax.ucsb.edu (Oreo Cat) writes:
>
>>The serial port on the host computer can be driven at up to
>>38400 bps, but unfortunatley the serial port on the LW+ only goes up to
>>9600.  I am told that the appletalk connection runs at something like
>>64 kbps.  Is there any way of connecting this to a serial port?  Or is
>>there any way of making the serial port run faster than 9600?
>>  It now looks like we'll be printing more of the bitmaps, so any
>>cheap solutions to this problem would be greatly appreciated!
>
>Implement a postscript decompresso program--one that "unsqueezes" data
>as it comes through the pipe--download it to the printer, then do the
>reverse on the computer.  With some simple escapes, you could massively
>increase throughput on nearly any large file.
>
>Comments?
>	
>		Alex

Comments ? yes. Look for a simpler solution.
Actually both the LaserWriter plus and the NT (so I guess the NTX as well)
can run up to 38Kbaud, it's my Apollo that can't run at more than 19Kbaud !
Look in the Appendix of the Red Book, where the laserwriter dependent
commands are, and download a PS program to permanently change the speed.

I don't have the book handy now, but I seem to remember that 19K and 38K
are not documented, just extrapolate from the command that changes the 
speed what 19k or 38k should look like and run it.

By the way you can change independently the speed on the 25 pin port and
on the 9 pin port. I'd recommend that you set one of them to 9600 baud
before, then you test it, and when you're sure everything works, you reset
the other to 38k. This insures that you can still talk to the printer
even if you do a mistake.

Hope this helps,

	Achille Petrilli
	Cray & PWS operations

hastings@hemlock.Berkeley.EDU (Mark Hastings) (01/11/90)

In article <1200@cernvax.UUCP>, achille@cernvax.UUCP (achille petrilli) writes:
> 
> [ ... ]
> 
> By the way you can change independently the speed on the 25 pin port and
> on the 9 pin port. I'd recommend that you set one of them to 9600 baud
> before, then you test it, and when you're sure everything works, you reset
> the other to 38k. This insures that you can still talk to the printer
> even if you do a mistake.

Has anyone heard of another "safety valve" feature of the Laserwriter
that allows you
to reset the EPROM settings in case you accidentally screw up the baud
rate?  I've
been reluctant to try any of these speedups unless I knew I could return
things to
normal if problems arose (and finding a 9-pin serial cable for our sun
would take
a long time).

Also, does anyone really trust a Sun 3/60 serial port to go much faster
than 19.2kb?

--Mark Hastings           			(415) 642-4611
  hastings@ernie.berkeley.edu			..!ucbvax!ernie!hastings

jef@well.UUCP (Jef Poskanzer) (01/11/90)

In the referenced message, ericbi@microsoft.UUCP (Eric BIDSTRUP) wrote:
}In article <1990Jan10.042555.19571@grian.cps.altadena.ca.us>, alex@grian.cps.altadena.ca.us (Alex Pournelle) writes:
}> Implement a postscript decompresso program
}
}As someone who has attempted to do this before, I recommend you
}save yourself the time & energy.  What happened (in my case) was
}that the decompression routine took longer to execute & translate
}the data stream than simply sending the same data in a non-compressed
}format.  I also remember seeing a thread here or on CIS about the
}same idea a year ago w/ others having similiar results.

That was here.  As I recall, I posted my version of the PostScript
decompression routine (as generated by the PBMPLUS program pgmtops),
noted the same thing as you (that the compressed version took longer to
execute than the uncompressed took to transmit), and asked whether any
better PostScript hackers could come up with a more optimal routine
that might be a win.  I got about five different versions posted or
mailed, and none were faster than uncompressed.

However!  That was at AppleTalk speed.  And even then, the uncompressed
bitmap was only about twice as fast as the compressed.  At 9600 or even
38400, the compressed definitely wins by a large factor.  Since Jim
says he is limited to using the serial line, compressing sounds like a
good plan.

Appended below is a sample bitmap done with the decompression routine.
---
Jef

  Jef Poskanzer  jef@well.sf.ca.us  {ucbvax, apple, hplabs}!well!jef
              "You tweachewous miscweant!" -- Elmer Fudd

%!PS-Adobe-2.0 EPSF-2.0
%%Creator: pgmtops
%%Title: a.ps
%%Pages: 1
%%BoundingBox: 295 392 316 399
%%EndComments
%%EndProlog
/rlestr1 1 string def
/rlestr 128 string def
/readrlestring {
  currentfile rlestr1 readhexstring pop  0 get
  dup 127 le {
    currentfile rlestr 0  4 3 roll  1 add  getinterval
    readhexstring  pop
  } {
    256 exch sub  dup
    currentfile rlestr1 readhexstring pop  0 get
    exch 0 exch 1 exch 1 sub { rlestr exch 2 index put } for
    pop  rlestr exch 0 exch getinterval
  } ifelse
} bind def
%%EndProlog
%%Page 1 1
gsave
295.92 392.64 translate
20.16 6.72 scale
21 7 1
[ 21 0 0 -7 0 7 ]
{ readrlestring }
image
fdff11bb8f1f9376efab76efbb76efbb8f1fffffff
grestore
showpage
%%Trailer

woody@rpp386.cactus.org (Woodrow Baker) (01/11/90)

In article <17612@rpp386.cactus.org>, woody@rpp386.cactus.org (Woodrow Baker) writes:
> In article <3495@hub.UUCP>, jim@cavevax.ucsb.edu (Oreo Cat) writes:
> > you.  We have an Apple Laserwriter Plus here in our lab.  Occaisonally
> > we have to print out large bitmapped images.  Since our printer is 
> > hooked up to a serial line, it is limited to 9600 bps.  Since bitmaps
> > 38400 bps, but unfortunatley the serial port on the LW+ only goes up to
> > 9600.  I am told that the appletalk connection runs at something like
> > 64 kbps.  Is there any way of connecting this to a serial port?  Or is
> > there any way of making the serial port run faster than 9600?
> Off hand, there are 2 possbilities.  The first is to get a larg printer buffer,
> and the second involves changing the baud rate.  You can indeed set the
> printers baud-rate to a higher value.  Don Lancaster runs his at 57Kbaud, over
> the serial line, but it is unidirectional only.  I'd suggest that you could
> set the baud-rate on the printer to 38.4k and try it.  you can always reset
> it back.  Just use the command as it is documented in your suppliment, but
> change 9600 to say 19200 or 38400 and try it.  Alternatly you can call Don
> at 602-428-4073 and pick his brains.  He's fairly helpful.

Some one dropped me a note to the effect that he runs his at 19200, but
once it is changed, if it doesnot work, you can't rechange it.  Remember
that switch position 0 is 1200 buad ps, and it is FIXED.  You cannot overide
the baudrate here.   You always can get in and change the baudrate through
this switch setting.  Then changing it to 1, will allow you back at the reset
baud rate.  If you have a paralell, you can also change the baudrate through it.

> 
> Cheers
> Woody

woody@rpp386.cactus.org (Woodrow Baker) (01/11/90)

In article <21091@pasteur.Berkeley.EDU>, hastings@hemlock.Berkeley.EDU (Mark Hastings) writes:
> In article <1200@cernvax.UUCP>, achille@cernvax.UUCP (achille petrilli) writes:
> > 
> Has anyone heard of another "safety valve" feature of the Laserwriter
> that allows you
> to reset the EPROM settings in case you accidentally screw up the baud
> rate?  I've
Yes.  Switch position 0 is ALWAYS 1200 baud so you can get in and reset things.
if you have a centronics port you can also do it that way.
Don Lancaster tells me that you can reset the machine by switching from serial
to Appletalk, waiting 3 seconds and then switching back, or something like that.
give him a call at 602-428-4073 for details.

Cheers
Woody
 

> 
> --Mark Hastings           			(415) 642-4611
>   hastings@ernie.berkeley.edu			..!ucbvax!ernie!hastings

guym@ibmpcug.co.uk (Guy Martin) (01/11/90)

In article <21091@pasteur.Berkeley.EDU> hastings@hemlock.Berkeley.EDU (Mark Hastings) writes:
> In article <1200@cernvax.UUCP>, achille@cernvax.UUCP (achille petrilli) writes:
> > By the way you can change independently the speed on the 25 pin port and
> > on the 9 pin port. I'd recommend that you set one of them to 9600 baud
> > before, then you test it, and when you're sure everything works, you reset
> > the other to 38k. This insures that you can still talk to the printer
> > even if you do a mistake.

> Also, does anyone really trust a Sun 3/60 serial port to go much faster
> than 19.2kb?
> 
> --Mark Hastings           			(415) 642-4611
>   hastings@ernie.berkeley.edu			..!ucbvax!ernie!hastings

Well I've got a Sun 3/60 here that drives a Laserwriter IINT at 38400
with no problems at all. I'm running SunOS4.0.3. It ran at 38400 on a
3/50 as well ....

I've been using it like this for at least a year - I'd say I trust the
Sun serial ports.

Guy Martin
guym@ibmpcug.co.uk
grmartin@cix.cix.uucp
-- 
Automatic Disclaimer:
The views expressed above are those of the author alone and may not
represent the views of the IBM PC User Group.
-- 
Guy Martin                               guym@ibmpcug.co.uk
Phoenix Business Forms Limited        grmartin@cix.cix.uucp
Mallard Close, Acocks Green
Birmingham B27 6BW. ENGLAND.

cet1@cl.cam.ac.uk (C.E. Thompson) (01/11/90)

In article <21091@pasteur.Berkeley.EDU> hastings@hemlock.Berkeley.EDU (Mark Hastings) writes:
>Has anyone heard of another "safety valve" feature of the Laserwriter
>that allows you
>to reset the EPROM settings in case you accidentally screw up the baud
>rate?  I've
>been reluctant to try any of these speedups unless I knew I could return
>things to
>normal if problems arose (and finding a 9-pin serial cable for our sun
>would take
>a long time).
>

That's what the "1200" position of the four-position switch is for.
Setting the switch in this position causes it to ignore the eeprom settings,
and drive both serial ports at 1200 baud, parity ignored. Provided that
you can drive the connection with these options, you have a way of backing
off from bad eeprom settings.
 
Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk

amichiel@rodan.acs.syr.edu (Michielsen) (01/12/90)

In article <17612@rpp386.cactus.org> woody@rpp386.cactus.org (Woodrow Baker) writes:
>In article <3495@hub.UUCP>, jim@cavevax.ucsb.edu (Oreo Cat) writes:
>> we have to print out large bitmapped images. 
>> I am told that the appletalk connection runs at something like
>> 64 kbps.  Is there any way of connecting this to a serial port?  Or is
>> there any way of making the serial port run faster than 9600?

>  I'd suggest that you could
>set the baud-rate on the printer to 38.4k and try it.  you can always reset
>it back.  Just use the command as it is documented in your suppliment, but
>change 9600 to say 19200 or 38400 and try it.

I have 3 comments to add to the previous reply & recommendation.
1. I'd change whichever switch setting is less used, probably the 1200 port.
   (I'm pretty sure it can be changed, but I didn't look it up today.)
2. There may be a program function for autobaud 300-38K, It is implemented on
   at least one postscript printer, but possibly not the apples
3. If you are using a ibm pc, there are local-(apple)-talk boards available.
   One of these would be fine if it will work with your software.
4. You could use the functions of (semi-)-high speed network between ibm's &
   Macs & use a mac as a print spooler & appletalk comverter. Either with a
   laser NTX, or like a Tops & novell net.

In any case, I'd definately try a higher baud first & try my best to live with
it.  All of the other 3 have some (almost serious) drawbacks to consider.

AL

drl@corpane.UUCP (Dan Lance) (01/12/90)

In article <21091@pasteur.Berkeley.EDU> hastings@hemlock.Berkeley.EDU (Mark Hastings) writes:
>Has anyone heard of another "safety valve" feature of the Laserwriter
>that allows you
>to reset the EPROM settings in case you accidentally screw up the baud
>rate?  I've
>been reluctant to try any of these speedups unless I knew I could return
>things to
>normal if problems arose (and finding a 9-pin serial cable for our sun
>would take
>a long time).
>
>Also, does anyone really trust a Sun 3/60 serial port to go much faster
>than 19.2kb?

The serial ports on all Sun 3 motherboards will reliably do 38400 baud.  When
I used to work with Suns, I ran our LaserWriter at 38400 baud without
a hitch through the Sun-supplied printer cable.  Of course, if your printer
is located a good distance from the 3/60, you may not be able to use the
higher baud rates.  Try it and see.

As for screwing up the baud rate:  the program to change the baud rate
needs to be sent to the printer only once, as the information is not stored
in RAM.  If you are careful I doubt you will have any problems.

>--Mark Hastings           			(415) 642-4611
>  hastings@ernie.berkeley.edu			..!ucbvax!ernie!hastings

--drl
Dan Lance / Corpane Industries, Louisville KY 
...!uunet!corpane!drl  corpane!drl@ddsw1.mcs.com  corpane!drl@e.ms.uky.edu
-- 
--drl
Dan Lance / Corpane Industries, Louisville KY 
...!uunet!corpane!drl  corpane!drl@ddsw1.mcs.com  corpane!drl@e.ms.uky.edu

eric@batcomputer.tn.cornell.edu (Eric Fielding) (01/15/90)

I successfully changed the baud rate on our LaserWriter Plus to 19200 baud
(the fastest that our MicroVAX II terminal board seems to support), but I was
unable to change the baud rate on our 'original' LaserWriter.  It failed with
a 'rangecheck' so I assume that it can't go faster than 9600 baud.  The PS
program that Amanda Walker posted did not include the 'exitserver' command
that is needed to access the 'statusdict', which is probably a good idea as
anyone who doesn't know about 'exitserver' should not be messing with the baud
rate anyway.  Thanks for posting this info!

				++Eric Fielding

brian@advsys.UUCP (Brian Rippon) (01/17/90)

In article <15469@well.UUCP> Jef Poskanzer <jef@well.sf.ca.us> writes:
>That was here.  As I recall, I posted my version of the PostScript
>decompression routine ...			 and asked whether any
>better PostScript hackers could come up with a more optimal routine
>that might be a win.  I got about five different versions posted or
>mailed, and none were faster than uncompressed.

I wasn't reading news then, so forgive me if this has been covered.
Was the FrameMaker technique discussed? The PostScript is Copyright
Frame Technology, Inc, so you'll have to find your own Frame output
to see what I mean (how about it Frame?). Essentially they run-length
encode short runs to a byte, allow unencoded strings prefixed by a
byte, and repeated bytes as a byte followed by the pattern. The decode
is performed by a lookup from the byte to an array of procedures.

Trying the technique on a typical(?) Sun screen (several text windows,
mailtool, dbxtool, some grey background), it generates 37k of PS, compared
with 260k using the normal method. Considering that the compress'd version
of the latter is 22k, that's not bad. In Group 3, it's 70k!

Running a QMS PS-800+ from a Sparc at 38400, I get execution times
of 55 seconds compared with 67 seconds for uncompressed. As Jef says,
not worth it on AppleTalk or Centronics, but I don't have a choice;
anyway Centronics from a PC is no great shakes.

I don't know how this compares with Jef's code - I haven't found
a local copy of PBMPLUS yet :(.

Brian.