Terminal emulation program for ibm® pc 53 – Red Lion TCU User Manual
Page 61
Terminal Emulation Program For IBM
®
PC
Utilizing the Serial communications capability of the TCU requires the use
of an RS485 serial card in the computer. If an IBM
®
PC compatible computer
is used, the RS485 serial card is installed in an expansion slot on the
mo t h e r - b o a r d . T h e R S 4 8 5 c a r d s h o u l d b e c o n f i g u r e d f o r “ 2 - w i r e
half-duplex” operation. For this mode of operation, each piece of equipment
must be able to switch from receive mode to transmit mode and vice-versa.
The controller is normally in the receive mode. It automatically switches to
the transmit mode when a Transmit Value Command or a Print Request is
issued. For the computer to switch from receive to transmit mode, the
controlling software must be written to perform this task. On most RS485
serial cards, the RTS (Request-to-Send) signal can be configured to be used
as the direction (transmit/receive) control signal. The controlling software
must switch the state of the RTS line when the computer is to switch from
transmitting to receiving data. The controller allows 100 msec minimum for
the computer to switch from transmit to receive mode.
Listed at right is a BASIC program that emulates a terminal. It is written
using IBM
®
PC BASIC. The program may need to be modified if using a
different BASIC interpreter. Set up the TCU for a baud rate of 9600. When the
program is running, commands can be typed in from the keyboard as shown in
the previous examples. An asterisk (*) is used to end all commands. Do not
use the carriage return to end a command
REM “FOR THIS PROGRAM TO WORK THE ”RS-485" CARD SHOULD BE
SET-UP AS COM2"
2 REM “ALSO THE CARD SHOULD USE ”RTS" FOR HANDSHAKING"
3 REM “THE TCU UNIT SHOULD BE SET-UP FOR 9600 BAUD, AND ODD
PARITY”
4 TXEMPTY = &H60
5 LSR = &H2FD: REM “COMM2 LINE STATUS REGISTER”
6 MCR = &H2FC: REM “COMM2 MODEM CONTROL REGISTER”
10 CLS : CLOSE :
20 OPEN “COM2:9600,0,7,1" FOR RANDOM AS #1
30 ON TIMER(1) GOSUB 300
40 A$ = INKEY$: IF A$ < > “ ” THEN GOTO 1000: REM “CHECK FOR
KEYBOARD INPUT”
50 IF LOC(1) = 0 THEN 40 ELSE 80: REM CHECK FOR INPUT
60 IF LOC(1) = 0 THEN 80: REM “SKIP CLEARING OF BUFFER”
70 B$ = INPUT$(LOC(1), #1): REM “CLEAR BUFFER”
80 F = INP (MCR) AND 253: OUT MCR, F: REM “SET FOR RECEIVE
MODE”
90 IF INP(LSR) < > TXEMPTY THEN 90: REM “WAIT UNTIL DONE
TRANSMITTING”
100 TIMER ON
110 IF LOC(1) = 0 THEN 110
120 B$ = INPUT$(1, #1)
130 IF B$ = CHR$(10) THEN 160" REM “TO PREVENT DOUBLE SPACING
ON PRINT”
140 PRINT B$;
160 IF NOT B$ = “ ” THEN GOTO 90
170 TIMER OFF
200 GOTO 40
300 TIMER OFF: RETURN 40
1000 D = INP(MCR) OR 2: OUT MCR, D: REM “SET FOR TRANSMIT
MODE”
1010 PRINT #1, A$; : PRINT A$; : REM “PRINT KEYSTROKE”
1020 IF A$ = “Q” THEN PRINT
1030 IF A$ = “Q” THEN IF INP(LSR) < > TXEMPTY THEN 1030 ELSE
GOTO 60
1040 A$ = INKEY$: IF A$ < > “ ” THEN GOTO 1000
1050 GOTO 1010
53