IM 05C01E22-10E
3-22
Example of the Program Created Using Microsoft Quick BASIC Version 7.1
(Reads the values in three D registers from register 0002.)
1000
‘
=== Main routine ===
1010
STX$=CHR$(2)
‘ Define
1020
ETX$=CHR$(3)
‘ Define
1030
CR$=CHR$(13)
‘ Define
1040
RCVCHR$= “”
‘ Initialize receive character string
1050
fRCVEND=0
‘ Initialize flag
1060
fTIMEOUT=0
‘ Initialize flag
1070
‘
1080
SEND$=STX$+”01010WRDD0002,03"+ETX$
‘ Create character string for send
1090
‘
1100
OPEN “COM1:9600,N,8,1,ASC” FOR RANDOM AS #1
‘ Open a port
1110
ON COM(1) GOSUB receivechr
‘ Specify interruption processing during
receiving
1120
ON TIME(5) GOSUB timeout
‘ Specify interruption processing at timeout
1130
‘
1140
PRINT #1,SEND$
‘ Send
1150
COM(1) ON
‘ Permit interruption during receive
1160
TIMER ON
‘ Start timer
1170
‘
1180
DO
‘ Wait for receive end or timeout
1190
LOOP WHILE fRCVEND=0 AND fTIMEOUT=0
‘
1200
‘
1210
TIMER OFF
‘ Stop timer
1220
COM(1) OFF
‘ Prohibit interruption during receiving
1230
CLOSE #1
‘ Close the port
1240
‘
1250
PRINT “>”+SEND$
‘ Display sent character string on screen
1260
PRINT “<”+RCVCHR$
‘ Display received character string on
screen
1270
END
‘ END
1280
‘
1290
‘
=== Subroutine ===
1300
receivechr:
‘ Interruption processing during receiving
1310
CHR1$=INPUT\(1,#1)
‘ Fetch characters from receive buffer
one by one
1320
IF CHR1$=CR$ THEN
‘ If received character string is “CR,”
1330
IF RCVCHR$=SEND$ THEN
‘ If received character string is the same
served command,
1340
RCVCHR$=
“”
’ Initialize receive character string. (Echo
Back Processing)
1350
fRCVEND=0
‘ receiving flag remains initialized at 0.
1360
ELSE
‘ If received character string is different
from served command,
1370
fRCVEND=1
‘ receiving end flag is set.
1380
END IF
‘
1390
ELSE
‘ If it is a character other than CR,
1400
fRCVEND=0
‘ receiving end flag remains initialized at 0.
1410
RCVCHR$=CHR1$
‘ Create received character string
1420
END IF
‘
1430
RETURN
1440
‘
Summary of Contents for UT150L
Page 1: ...User s Manual Model UT150L Communication Functions IM 05C01E22 10E IM 05C01E22 10E 3rd Edition...
Page 2: ......
Page 8: ...IM 05C01E22 10E vi Appendix Table of ASCII Codes Alphanumeric Codes App 1 Revision Record i...
Page 12: ...IM 05C01E22 10E 1 4...
Page 14: ...IM 05C01E22 10E 2 2...
Page 38: ...IM 05C01E22 10E 3 24...
Page 48: ...IM 05C01E22 10E 4 10...
Page 54: ...IM 05C01E22 10E 6 2...
Page 56: ...IM 05C01E22 10E App 2...
Page 58: ......
Page 59: ......