RE: [ILUG] Serial Port Logging

From: Kenn Humborg (kenn at domain bluetree.ie)
Date: Wed 19 Sep 2001 - 14:17:19 IST


> Duplex is not an issue as this is a dumb, text only printer.

If the baud rate isn't too high, then call the guys at
www.bb-europe.com (they're located near Galway) and ask
for one of these:

   http://www.bb-europe.com/product.asp?dept%5Fid=13&sku=232CDT

(There's also a slightly cheaper 9-pin version.) Simply
insert this into the serial line to the printer and connect
your linux box to the tap connector.

Then do something like:

   cat /dev/ttyS0 > printer.log

If the data is too fast and you get dropouts in printer.log, then
just get a faster linux box.

A more "production version" would something along the lines of
/usr/local/bin/printlog

   #!/bin/sh

   mkdir -p /var/log/printlog
   chmod 700 /var/log/printlog

   echo $$ > /var/run/printlog.pid

   cat /dev/ttyS0 > /var/log/printlog/`date "+%Y-%m-%d-%H:%M:%S"`.log

And then an entry in /etc/cron.daily that does

   #!/bin/sh

   kill -INT `cat /var/run/printlog.pid`
   /usr/local/bin/printlog &

to rotate the logs (or use logrotate instead)

Later,
Kenn



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:12 GMT