127
V530-R2000
User’s Manual
SECTION 9
Appendix
FCS Che
c
k
Pr
ogr
a
mming E
x
a
m
ple
s
(BAS
IC
)
SECTION 9
FCS Check Programming Examples (BASIC)
n
Calculation Example for Sending FCS
n
FCS Check Subroutine Example for Received Data
DATA$
Sample data line
L
Data length
CODE$
Data character
A
Exclusive OR
100
'*****CALCULATE FCS*****
110
'*FCSSET
120
L=LEN(DATA$)
130
A=0
140
FOR J=1 TO L
150
CODE$=MID$(DATA$,J,1)
160
A=ASC(CODE$)XOR A
170
NEXT J
180
FCS$=HEX$(A)
190
IF LEN(FCS$)=1 THEN FCS$="0"+FCS$
200
RETURN
1000
'*****FCSHECK*****
1010
'*FCSHECK
1020
Q=0:FCSCK$="OK"
1030
PRINT RESPONSE $
1040
LENGS=LEN(RESPONSE$)-3
1050
FCSP$=MID$(RESPONSE$,LENGS+1,2)
'FCS in response data
1060
FOR J=1 TO LENGS
'Calculation range of FCS'
1070
Q=ASC(MID$(RESPONSE$,J,1))XOR Q
1080
NEXT J
1090
FCSD$=HEX$(Q)
1100
IF LEN(FCSD$)=1 THEN FCSD$="0"+FCSD$
'FCS calculated in a program
1110
IF FCSD$ < > FCSP$ THEN FCSCK$="ERR"
1120
PRINT "FCSD$=";FCSD$;"FCSP$=";FCSP$;
'FCS correctly received: OK
"FCSCK$=";"FCSCK$=" 'FCS not received correctly: ERR
1130
RETURN
Содержание V530-R2000
Страница 1: ...USER MANUAL Cat No Q134 E1 1A V530 R2000 2D Code Reader Fixed...
Страница 33: ...16 V530 R2000 User s Manual SECTION 2 MEMO...
Страница 55: ...38 V530 R2000 User s Manual SECTION 4 MEMO...
Страница 63: ...46 V530 R2000 User s Manual SECTION 5 MEMO...
Страница 111: ...94 V530 R2000 User s Manual SECTION 7 MEMO...