Operating System - HP-UX
1833758 Members
2003 Online
110063 Solutions
New Discussion

Re: Printing through a terminal?

 
SOLVED
Go to solution
Ryan Clerk
Frequent Advisor

Printing through a terminal?

Hello Gurus,

I think I have just been asked to do the impossible. We have an old application written in C. Currently reports are printed to serial printers connected to a modem for each printer. There is one phone connection for each terminal and a second phone connection for each user's printer. The manager has just realized that he could cut the monthly phone expenses in half if they could somehow print through the AUX/PRINTER port on the Wyse 60 terminal. My boss has told them that we can do this. Please help! Is this even remotely possible. I don't even know where to begin.

Thanks in advance, Ryan

10 REPLIES 10
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Printing through a terminal?

Wow, this must be an old beast.

Plan A) How about a dedicated connection and a pair of stat MUX'es? One MUX on your end and the other on theirs. Maybe 8 ports on each end. That might be cheaper and would require no code changes.

Plan B) Ryan gets to do some work. I just untic'ed wyse60 and you are in luck (more or less). The 'mc4' terminfo sequence turns the printer port off and the 'mc5' sequence turns the printer port on.

You can do a bit of a test by doing something like this:
PTRON=$(tputs mc5)
PTROFF=$(tputs mc4)

echo "${PTRON}\c"
echo "This should go to the printer."
echo "${PTROFF}\c"
echo "This should go to the screen."

Hopefully you are using curses in your application. In that case, you will be using the tputs() fuinction. Man curses for details.

I can't remember if the wyse60 does a transparent print or not; some terminals echoed everything to both the screen and the printer port. If you are lucky, the wyse60 does not garbage the screen while it's printing.

Happy coding, Clay


If it ain't broke, I can fix that.
Jeff Schussele
Honored Contributor

Re: Printing through a terminal?

Well Clay I guess you & I are old beasts.
Wy-60 sure does have transparent print, and it's just a simple escape sequence.

Transparent on => ESC d # (OR) CTRL-X
Transparent off => CTRL-T

OR you can use

AUX print mode on => CTRL-R
AUX print mode off => CTRL-X

Can't begin to count how many of these I installed over a 7 year period in the '80s/90s, but I'm pretty sure it was 4 figures....

Just alter the program to send one of these ON codes just prior to the print stream & follow it w/CTRL-X after the print stream & you should be good to go.

Notes:
1) IF you use either you will NOT be able to use the term for anything else 'til the print's done
2) These are the codes for the native Wy-60 mode...IF you are emulating anything else, all bets are off. I STRONGLY suggest you use the native mode.
3) Of course you'll have to insure the serial settings are correct on the port & ptr...particularly handshake. Make sure you send a LONG (longer than ptr buffer) doc thru to the ptr before you release it.
4) DON'T get fancy with the print jobs....it's easy to hit a ptr ctrl sequence that the terminal will act on if it's in it's control set. Bold, italic, u-line that's about all...graphics RARELY work.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Jeff Schussele
Honored Contributor

Re: Printing through a terminal?

Sorry, I'm a dummy....

AUX print mode off => CTRL-T

Either way CTRL-T turns print off.

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Pepe Jimenez Muñoz
Frequent Advisor

Re: Printing through a terminal?

Hi Ryan,

you can print in a printer attached to your terminal through TSM software.

I have HP 700/70 terminals and print to the laserjet connected to the parallel port.

You need in /home/user/.profile:

myterminal=`tty`
myprinter=`echo $myterminal | cut -d / -f 4`
TSMLP=i_$myprinter ; export TSMLP
tsm nonstop 2

You need in /home/user/.tsm:

window_title=SHELL 1
#respawn 1 $SHELL
# 1 /home/integral/setisc ; /usr/tsm/bin/tsm.command qy
1 /path/to/your/aplication
window_title=PRINTER CONTROL
2 /usr/tsm/bin/tsm.lpcat
tsm 2

To define the printer:

/usr/tsm/bin/tsm.lpadmin -p i_eb111 -m localp

Where eb111 is the port name in the DDFA file.

Hope this help.
ppviso
Ryan Clerk
Frequent Advisor

Re: Printing through a terminal?

Thanks very much guys.

I did a small test. I put some printf's with the external port on/off sequences supplied by Jeff and it works. It doesn't mess up the screen either. The curses screen remains intact.

Thanks for your help,
Ryan

A. Clay Stephenson
Acclaimed Contributor

Re: Printing through a terminal?

Hi Ryan:

While your approach will work, it's how shall I politely phrase this? It's Mickey Mouse. Since you are using curses, use it to your advantage. What happens if the customer suddenly buys a new, 'better', 'improved' (maybe not even Wyse) terminal. Your hard-coded sequences suddenly don't work anymore. Another point is suppose your customers finds a 'better' printer. If it were me I would do the terminfo lookup for the printer on and off AND I would not assume that the screen is not 'messed up'.

The really smart play would:
1) Save the current curses window/screen.
2) Use the printer on sequences found in the terminfo database to enable printing.
3) Print your stuff.
4) Use the printer off sequences found in the terminfo database to disable printing.
5) Refresh the curses window/screen.

An even more robust approach would use an ENV variable (e.g. EXTPRINTER) to define another
terminfo entry to describe the external printer. That way, double-width, underline, bold, etc. could be looked up as well.

If you follow this approach, no matter what is thrown at you, a few terminfo changes and you are done AND you can support various terminal/printer combinations.

P.S. I like Mickey Mouse cartoons; I detest Mickey Mouse code.

Regards, Clay
If it ain't broke, I can fix that.
Ryan Clerk
Frequent Advisor

Re: Printing through a terminal?

Gee Clay, how do you really feel? Actually, you made me stop and think about how to do this the 'right' way and you are, of course, correct. You mentioned something called a "stat MUX" in your first posting. What is that? I would like to tie up any loose ends before I talk to my boss and the customer.

Ryan
A. Clay Stephenson
Acclaimed Contributor

Re: Printing through a terminal?

stat MUX ==> Statistical Multiplexor

This is a device which combines a number of serial ports on one end and sends them over a single (usually leased) line to be demultiplexed into another set of ports on the other end. You might look at MultiTech; I know they made these things at one time. Stat MUX'es have largely been replaced by ATS units these days.
If it ain't broke, I can fix that.
MANOJ SRIVASTAVA
Honored Contributor

Re: Printing through a terminal?

Hi Ryan

Here is a small script that does the magic :

echo "\033[5i"
cat $*
echo "\033[4i"

jsut save this a lprint in bin of the machine , what this does is that when you run it with a file name it will print the file on the serial port of the termial attached to the printer , during this time ofcourse you can type anyhting on the terminal .


Manoj Srivastava
Ryan Clerk
Frequent Advisor

Re: Printing through a terminal?

Thanks everybody. I wound up following Clay's advice even about the second EXTPRINTER terminfo lookup. All of this was actually very easy and required only a few extra lines of C. I may still look into the "stat MUX" so that only one phone line might be needed for all four terminals and printers.

Thanks again,
Ryan