4. COMMUNICATION PROTOCOL
IMSRM04-E8
35
1360 *ETXRX
1370 DT$=DT$+K$
1380 BCCRX$=INPUT$(1,#1)
1390 BCCRX=ASC(BCCRX$)
1400 GOSUB *BCCCH
1410 IF BCC<>BCCRX THEN GOSUB *NAKTX
1420 IF BCC<>BCCRX THEN GOSUB *RXDT GOTO *J10
1430 '
1440 PRINT "Data has been correctly received"
1450 PRINT "Received data=";DT$ : END
1460 '
1470 '--------------------- Sub-routine ----------------------
1480 '
1490 *NAKTX
1500 PRINT "BCC error"
1510 DT$=NAK$
1520 GOSUB *TEXT
1530 RETURN
1540 '
1550 *RXDT
1560 DT$=""
1570 RETURN
1580 '
1590 *TEXT
1600 PRINT #1,DT$;
1610 RETURN
1620 '
1630 *BCCCH
1640 FOR II=1 TO LEN(DT$)
1650 BCCA$=MID$(DT$,II,1)
1660 IF BCCA$=STX$ THEN BCC=0 : GOTO *IINEXT
1670 BCC=BCC XOR ASC(BCCA$)
1680 *IINEXT
1690 NEXT II
1700 RETURN
(The items after the mark of " ' " can be omitted.)
BCC checking
Display of received data and
closing of RS-232C circuit
Processing on occurrence of a BCC error
Clearing of circuit buffer
Transfer of polling identifier
BCC calculation
Setting of the receiving waiting time : If timeout occurs in using high speed computer (Except no
response), the numeral value of 500 in the program should
be changed to an appropriately-sized numeral value.