Command and Response Formats
Example Program for FCS
Note
6-4-2
Commands from the PC
Reception Format
@
Node No. Header code
446
This example shows a BASIC subroutine program for executing an FCS
check on a frame received by the host computer.
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) ' ...
470 FOR I=1 TO LENGS ' ..........
480 Q=ASC(MID$(RESPONSE$,I,1)) XOR Q
490 NEXT I
500 FCSD$=HEX$(Q)
510 IF LEN(FCSD$)=1 THEN FCSD$="0"+FCSD$ ' ...
520 IF FCSD$<>FCSP$ THEN FCSCK$="ERR"
530 PRINT"FCSD$=";FCSD$,"FCSP$=";FCSP$,"FCSCK$=";FCSCK$
540 RETURN
1. 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 pos-
sibility.
2. In this program example, the CR code (CHR$(13)) is not entered for RE-
SPONSE$. When including the CR code, make the changes in lines 430
and 450.
In Host Link communications, commands are ordinarily sent from the host
computer to the PC, but it is also possible for commands to be sent from the
PC to the host computer. In Host Link Mode, any data can be transmitted from
the PC to the host computer. To send a command to the host computer, use
the TRANSMIT instruction (TXD(48)) in the PC program in Host Link Mode.
TXD(48) outputs data from the specified port (the RS-232C port, the periph-
eral port, or ports 1 or 2 of the Serial Communications Board). Refer to
page 417 for details on using TXD(48).
When TXD(48) is executed, the data stored in the words beginning with the
first send word is converted to ASCII and output to the host computer as a
Host Link command in the format shown below. The "@" symbol, node num-
ber, header code, FCS, and delimiter are all added automatically when the
transmission is sent. At the host computer, it is necessary to prepare in
advance a program for interpreting and processing this format.
E
X
122 characters max.
(Must be "EX")
One byte of data (2 digits hexadecimal) is converted to two characters in
ASCII for transmission, the amount of data in the transmission is twice the
amount of words specified for TXD(48). The maximum number of characters
for transmission is 122 and the maximum number of bytes that can be desig-
nated for TXD(48) is one half of that, or 61.
Text
FCS
Section 6-4
FCS data received
Number of characters in FCS
FCS result
*
↵
Terminator
Need help?
Do you have a question about the CQM1H - PROGRAM and is the answer not in the manual?