5-11 Example of Communication Program
5-26
1:n Protocol
100 ’***** V670-CD1D SAMPLE PROGRAM2 *****
110 CLS
120 OPEN “COM:E73NN” AS #1
’
Opens a RS-232C port.
130 ’
140 ’***** MAIN LOOP ****
150 *LOOP
160 LINE INPUT “Input TX Data : “, ITD$
’
Inputs a command data.
170 IP$=”00”+ITD$:GOSUB *FCS
’
Calculates FCS.
180 TXD$=CHR$(1)+IP$+OP$+”*”+CHR$(13)
’
Sets a data string to be sent.
190 PRINT “[TX] : ”;ITD$
’
Displays a command data.
200 PRINT #1,TXD$;
’
Sends a data string.
210 GOSUB *RECEIVE
’
Receives a data string.
220 PRINT “[RX] : “;REC$
’
Displays a response data.
230 GOTO *LOOP
240 ’
250 ’***** RECEIVE DATA *****
260 *RECEIVE
270 RXD$=” “
280 WHILE (LOC(#1)=0):WEND
290 WHILE (INSTR(RXD$,”*”+CHR$(13))=0)
300 RXD$=RXD$+INPUT$(1,#1)
310 WEND
320 IP$=MID$(RXD$,2,LEN(RXD$)-5):GOSUB *FCS
’
Calculates FCS
330 REC$=MID$(RXD$,4,LEN(RXD$)-7)
340 FCS$=MID$(RXD$,LEN(RXD$)-3,2):GOSUB *CHK.FCS
’
Checks FCS
350 RETRUN
360 ’
370 ‘***** CALCULATE FCS *****
380 *FCS
390 K=0
400 FOR I=1 TO LEN(IP$)
410 TMP$=MID$(IP$,I,1)
420 K=K XOR ASC(TMP$)
430 NEXT I
440 OP$=HEX$(K)
450 RETURN
460 ‘
470 ‘***** CHECK FCS *****
480 *CHK.FCS
490 IF FCS$<>OP$ THEN REC$=”FCS ERR!!”
500 RETURN
510 ’
520 END
Summary of Contents for V670-H11
Page 16: ...1 4...
Page 38: ...2 22...
Page 58: ...3 20...
Page 70: ...4 12...
Page 100: ...6 4...
Page 102: ...7 2 Unit mm 7 2 Outside Dimension...
Page 120: ...7 20...