6.6 Program Example
E5CK
6--13
J
Program list (language: IBM PC COMPATIBLE MACHINE)
1000 ’
1010 ’ PROGRAM : E5CK Communication Program
1020 ’
For IBM PC COMPATIBLE MACHINE
1030 ’ VERSION : 1.00
1040 ’ Copyright (C) 1995 OMRON Corporation All Rights Reserved.
1050 ’
1060 ’
RS-232C SPEED: 9600BPS, PARITY: EVEN, DATA: 7, STOP: 2
1070 OPEN ”COM: 9600, E, 7, 2, CD0, CS0, DS0, RB256, RS ”FOR RANDAM AS #1 LEN=256
1080 REPEAT
1090 ’
Make Command
1100 PRINT ”send data : ” ;
1110 INPUT SEND$
1120 ’
FCS calculation
1130 FCS=0
1140 FOR IFCS=1 TO LEN (SEND$)
1150 FCS=FCS XOR ASC (MID$ (SEND$, IFCS, 1))
1160 NEXT
1170 FCS$=RIGHT$ (”0”+HEX$ (FCS), 2)
1180 ’
Send data to communication port
1190 PRINT #1, SEND$+FCS$+”*”
1200 ’
Receive data from communication port
1210 RECCNT=0: TMP$=””
1220 DRECLOOP:
1230 IF LOC (1) <> 0 THEN DREC1
1240 RECCNT=1
1250 IF RECCNT=5000 THEN *DRECERR ELSE DRECLOOP
1260 ‘DREC1
1270 TMP$=TMP$+INPUT$ (LOC (1), #1)
1280 IF RIGHT$ (TMP&, 1)=CHR$ (13) THEN DRECEND
ELSE RECCNT=0: GOTO DRECLOOP
1290 DRECERR:
1300 TMP$=”No response !!”
1310 DRECEND:
1320 RECV$=TMP$
1330 PRINT ”response: ”; RECV$
1340 ’
Repeat to make Command
1350 GOTO REPEAT
1360 ’
END
1370 CLOSE #1
1380 END