Terminal emulation program for ibm ® pc 47 – Red Lion LEGEND User Manual

Page 49

Advertising
background image

TERMINAL EMULATION PROGRAM FOR IBM

®

PC

Utilizing the RS485 Serial communications capability of

the Legend Plus requires the use of an RS485 serial card in
the computer. If an IBM

®

PC compatible is used, this card

would be installed in an expansion slot on the mother-board.
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 Legend Plus is
normally in the receive mode. It automatically switches to
the transmit mode when a Transmit Value Command is
issued 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 Serial Transmit delay, “XMIT DLY”, of the Legend

Plus is used to give the computer time to switch from
transmit to receive mode. The delay can be programmed to
be either 0.002 or 0.100 second.

If an RS485 card cannot be obtained, and only an RS232

port is available, the Legend Plus unit has the capability of
operating directly from RS232 by changing the jumper
selection on the back of the unit. When using RS232, only
one Legend can be connected to the RS232 port.

Listed below is a basic program that emulates a terminal.

It is written using GW Basic. The program may need to be
modified if using a different Basic interpreter. Set up the
Legend Plus 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. When using this program, the Serial Transmit
Delay should be set to 0.100 second.

-47-

1 REM"FOR THIS PROGRAM TO WORK THE “RS485” CARD SHOULD BE SET-UP AS COM2"
2 REM “ALSO THE CARD SHOULD USE ”RTS" FOR HANDSHAKING"
3 REM “THE LEGEND PLUS 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$ = “*” THEN PRINT
1030 IF A$ = “*” THEN IF INP(LSR) < > TXEMPTY THEN 1030 ELSE GOTO 60
1040 A$ = INKEY$: IF A$ < > “” THEN GOTO 1000
1050 GOTO 1010

Advertising