Subject: Re: DeskWriter daemon - suggestions?
To: None <>
From: Bill Studenmund <wrstuden@loki.Stanford.EDU>
List: macbsd-development
Date: 07/03/1995 13:36:07
> I like Allen's suggestions about the daemon. I would be willing to help. I have
> actually written serveral daemons. I own a Deskwriter ( pre-Appletalk) and I'm
> dying to print from unix. Unfortunately, other than what is in my manual, I
> don't have any specs on the printer. To summarize a quick off the cuff design
> analysis:

Wow! It seems our skills dove-tail well! Your daemon-making skills
eclipse mine, and I'm building up info on making the beasties work.
If you want, we can team up & make this project work!

> 1) The daemon creates a server socket for the status. Each time a user process
> connects to this socket we add it to an update list.
> 2) We open an fd on the tty to read the status from the printer. When we get a
> new status, we check our update clients and broadcast the status to them. We
> also maintian the last status internally. If we have no clients, we either
> throw away the updates or log one every minute or something.

I think we'd want to stash the status internally. Then when we get
one client, or someone tries to print, we know what's up.

I'm not sure what's standard for logging. We might want to log paper-
outages and unexpected status codes (so we the programmers can learn
about new printers by trial & error :-) 

> 3) We provide another server socket for print requests. Each time we get a new
> connection we add it to an ordered request list. Now we process the requests as
> they arrive. Once we have a request to process, we loop writing some number of
> bytes to the printer and the checking our read fd's.
> 4) We do a select with the update server socket, the request server socket, and
> the fd from 2 as read fd's. When new info arrives on either, we process it
> according to 1, 2, & 3.
> What do you think? I'm not sure why you would want other processes accessing
> the printer directly. In practice, all the printing I have ever done
> professionally went through some kind of spooler.

I think it sounds good. My one idea with letting others have at the
port was I didn't know how the daemon would get the file. If it was
passed as a file name, then there is no reason to let others at the
tty. However, if something else is going to read a disk file then pipe
it to the daemon, that seems like a waste. (N.B. I do realize the
daemon might get fed a pipe at some point when the output is coming
directly from the generating process. :-)

Oh, if you just want to get some letters on paper, the printer will
print raw text in a fixed-point font. To configure the serial port, type

stty -f /dev/tty01 57600 mdmbuf

which sets the printer port to 57600 bps and DTR handshakeing. All the
other defaults in my kernel (the mit happy-IIsi one) seem correct,
though I only got my computer up last night after I took a soldering iron
to my dead 13" monitor :-)

cat * > /dev/tty01

seems to print OK though I did have one process hang the serial port
while I was mucking around.

Oh, you might notice some random F's and D's. I don't know where they
are coming from other than somewhere in the kernel. It's in the
to-fix list.

I'll contact you via private EMail.

Take care,


> Tim B.