Hot to set up a serial port to emulate a serial printer
Message-ID: <3A33D927.A10CF39@home.se>
Date: Sun, 10 Dec 2000 20:27:35 +0100
From: Lars Karlsson
Message-ID: <004101c06301$74bf8700$0b0aa8c0@alpha>
From: "Andrew Smith"
I want to do something that perhaps sounds odd, but here goes...
I want to use a SuSE 6.3 machine as a kind of "reverse print server" for serial printing. I want to attach this machine to a serial cable from a process computer and let it act as a serial printer. I need it to receive the print data and pipe it to lpr. Possibly by first saving it to a temporary file and then print that file to a normal printer configured as usual. Can someone help me on this? Help will be very much appreciated :)
Kindest regards,
Lars Karlsson
-- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/support/faq
Message-ID: <3A357518.46E7400@home.se>
Date: Tue, 12 Dec 2000 01:45:12 +0100
From: Lars Karlsson
Hi
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.
Regards,
Andrew
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! |
participants (3)
-
andrew@andrewsmith.plus.com
-
bernie@innovative.iinet.net.au
-
lars.k@home.se