From: Bernd Felsche
What I didn't explain in the mail is that the process computer can send either of plain text (ordinary production report lists) or postscript (coloured moist profile diagrams). My idea of using a Linux machine here is that:
1. It can be put in the place where the process computer is + it can be hooked on to our PC-network.
2. The printer can be anywhere, where there is a network jack in the wall :)
3. The Linux machine will handle both the plain text and the postscript printing and convert if necessary to a printing format that a cheap colour ink-jet printer can understand.
4. We could get away with a cheap off-the-shelf ink jet printer instead of an inkjet or colour laser with expensive postscript module.
My idea is that I configure a printer with apsfilter and then print the received data to that printer with lpr. Just forwarding the serial port to the parallell printer port is not enough. I guess a solution based on dd could work, but I would need a script to do it all.
dd if=/dev/ttyS0 of=/tmp/printdata.tmp
cp /tmp/printdata.tmp /tmp/printdata rm /tmp/printdata.tmp lpr /dev/printdata -Plp1
But I guess one would need more. One would need to know the start and the end of received data and when the file should be closed. The script would have to handle all this automagically...
Perhaps a script that can look for form feed characters in the incoming data? BOF - EOF?
That sort of stuff is generally not guarranteed. Does the process controller toggle one of the serial control lines when trying to print? That would normally be DTR. You could connect that to the carrier-detect (DCD) pin of the serial port and use modem control. The rough-cut interface script then becomes serial=/dev/ttyS2 while : ; do ( stty 9600 # speed and other stuff cat ) < $serial | lpr -Plp1 done Set it up to run in background through rc3.d for example. The sub-shell will stall until "carrier" is detected and then set speed etc before taking all input and dumping it to stdout which is the pipeline to lpr.
Or could pipes be used???
Sure. No temporary files; no mess. :-)
I don't know enough to know how to do it all
I believe this will be complicated :(((
It's pretty simple if you can take advantage of what the system provides and not _fight_ it. If it looks to be getting too complex, then look at the interface details.
Andrew Smith wrote:
This is only a guess at a starting point... try the command 'dd' - it copies data from one source to another. For example:
dd if=/dev/ttsy01 of=/dev/lp1 bs=1k
*should* copy all data from the com port to the printer port. The above probably wont work and it doesn't let the data be copied to disk, although it may provide you with a starting point.
-- /"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia \ / ASCII ribbon campaign | I'm a .signature virus! | X against HTML mail | Copy me into your ~/.signature| / \ and postings | to help me spread! |