[Coco] Christmas present?
Gene Heskett
gene.heskett at verizon.net
Thu Dec 24 14:09:18 EST 2009
Greets & Merry Christmas everybody;
I've been trying to figure out what to give as a Christmas present, and since
I was battling trying to make my joydrv code work in a program I wrote,
borrowing heavily from MaxIC 15 years ago (but not succeeded yet), and I
needed printouts to refresh my aging wet ram (if that's even possible) so I
thought I'd pass on what I have learned (all over again it seems) today.
My lashup is a connection from the coco's bit-banger to an FTDI ser<->usb
adaptor, thence to a powered usb hub, which is in turn plugged into a 16' usb
extension cable/hub, which is by way of another hub or 2 connected to this
machine. Ain't USB wunnerful?
The first problem was that an xmode /p bau=6 was getting me about 15 kilobaud
out of /p, seems the tuneport /p showed a timing value of 13, and I had to
run it up to 30 before the output baud rate was close enough to 9600 that the
FDTI adapter could recognize it as valid data. That needs fixed in the next
nitros9-3.2.x distribution, but since it can and is now in the startup file,
its not a showstopper.
Then for some reason, the version of cocod I had started, which captures the
data coming from the coco, on this box, in this case (linux, F10 TBE), is
/dev/ttyUSB1, saving it to a file in /tmp/CoCo as CoCoPrint-*.tmp where the *
is a rotating 1-25 sequence number so that the last 25 print jobs are cached,
had decided not to rename the file without the .tmp before passing the
filename to the coco_print utility, which in turns runs the text through cups
& whathaveyou to make it a raster image printable on a Brother-HL2140 B&W
laser printer.
So that is now fixed and I have my printouts (list filename >/p) from the
coco just fine. Those 2 small files are attached. Put them someplace that
is NOT in the $PATH so linux has to be told exactly where they are as that is
faster, so I put mine in /usr/local/libexec. Save them there, and set the
exec bits. You may have to make root own them.
It will also, if it has rights, make a /var/log/coco_print.log, with about 6
lines of info from some debugging statements from each print job processed,
could be simplified to just 2 lines probably, but with terrabyte drives (I
have 3.5 Tb of drives in this box), a little verbosity isn't that big a deal.
It would be if you were running linux on a 10Gb drive of course.
The invocation line, which you can put in your /etc/rc.d/rc.local file if the
hub and printer downstairs (or wherever) is powered up when you boot your
linux box, other wise you might want to make it a bash script to be run when
you need it:
#> /usr/local/libexec/cocod /dev/ttyUSB1 Brother-HL2140 &
Without the #> of course.
Obviously adjust the 1st argument to where you put cocod and coco_print, and
the 2nd and 3rd arguments to match your system. The coco's /p port comes in
here on /dev/ttyUSB1, and the printer is known by its name in the lp database
these days.
Now you can have a modern printer available for your coco os9/nitros9 use.
And once it starts, which will be 3 to 5 seconds after the prompt returns
from doing the listing, this one is 20 some pages a minute. Kewl IMO.
And you can use up those dead trees too. :-)
Merry Christmas everybody.
--
Cheers, Gene
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Never explain. Your friends do not need it and your enemies will never
believe you anyway.
-- Elbert Hubbard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cocod
Type: application/x-shellscript
Size: 4674 bytes
Desc: not available
URL: <http://five.pairlist.net/pipermail/coco/attachments/20091224/57be768a/attachment.bin>
-------------- next part --------------
# child still has OutFile open as stdout, close it
exec 1>&- # check syntax for closing a file descriptor
FileToPrint=${1:?need a file name}
#Default to the epson in B&W mode, but use the Brother if available
DefLp=lp0
OutLp=${2:-${DefLp}}
echo $FileToPrint $OutLp >>/var/log/coco_print.log
if ! [[ -f $FileToPrint ]] || ! [[ -r $FileToPrint ]]
then
# error handling for missing file
echo "No file to print, sorry." >>/var/log/coco_print.log
exit
fi
# got a file, echo where its going to the log
echo $FileToPrint $OutLp >>/var/log/coco_print.log
# Now, if the printer is turned off, just let it be so its cached
# the system is nice enough to delete /dev/usb/lp1 when it no longer powered up
# Change below to match your setup. One could also send it to lp0, my c82 with B&W profile
if [[ -e "/etc/cups/ppd/"${OutLp}".ppd" ]]
then
lp -d $OutLp -o cpi=12 -o lpi=7 < $FileToPrint >>/var/log/coco_print.log
echo $FileToPrint" sent to "$OutLp >>/var/log/coco_print.log
else
# echo using alternate printer lp0 >&2
# lp -d lp0 -o cpi=12 -o lpi=7 < $FileToPrint
echo "The brother is turned off or disconnected - Saving file." >>/var/log/coco_print.log
# But where does it save it? The log is 20 MB of junk from failed prints!
# $FileToPrint seems to be going to the log file.
fi
# If we don't do something with it, the drivers will nag you incessantly & must be killed
More information about the Coco
mailing list