![background image](http://html1.mh-extra.com/html/omron/srm1-programing-02-2001/srm1-programing-02-2001_programming-manual_742414260.webp)
4-3
Section
CPM2A/CPM2C Communications Functions
240
This example shows a BASIC subroutine program for executing an FCS check
on a frame received by the host computer.
Normal reception data includes the FCS, delimiter or terminator, and so on.
When an error occurs in transmission, however the FCS or some other data may
not be included. Be sure to program the system to cover this possibility.
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
400 *FCSCHECK
410 L = LEN ( RESPONSE$ ) ’
Data transmitted and received
. . . . . . . . . . . . . . . . . . . . . . . . .
420 Q = 0 : FCSCK$ = ” ”
430 A$ = RIGHT$ ( RESPONSE$ , 1)
440 PRINT RESPONSE$ , A$ , L
450 IF A$ = ”*” THEN LENGS = LEN ( RESPONSE$ ) – 3
ELSE LENGS = LEN ( RESPONSE$ ) – 2
460 FCSP$ = MID$ ( RESPONSE$ , LENGS + 1 , 2 ) ’
FCS data received
. . . . . . . . . .
470 FOR I = 1 TO LENGS ’
Number of characters in FCS
. . . . . . . . . . . . . . . . . . . . . . . . .
480 Q = ASC ( MID$ ( RESPONSE$ , I , 1 ) ) XOR Q
490 NEXT I
500 FCSD$ = HEX$ ( Q )
510 IF LEN ( FCS0$ ) = 1 THEN FCSD$ = ” 0 ” + FCSD$ ’
FCS result
. . . . . . . . .
520 IF FCSD$ < > FCSP$ THEN FCSCK$ = ” ERR ”
530 PRINT ” FCSD$ = ” ; FCSD$ , ” FCSP$ = ” ; FCSP$ , ” FCSCK$ = ” ; FCSCK$
540 RETURN
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Example Program for
FCS