App - 36 App - 36
MELSEC-Q
APPENDIX
Appendix 7.3 Break Control
If a BASIC program in the communication module receives data from an external
device, only data up to the break character specified by the control interface is stored
in the variable.
If the break character is not detected within the number of characters requested at a
receive request, reception data for the number of requested characters is stored in the
variable.
The break character can be specified in the ZRECEIVE instruction used to request
data reception.
(Depending on the character length at the time of transmission, any data
corresponding to the codes from 00h to FFh can be specified as the break character.)
Appendix 7.3.1 Break character specifying side
The following is an example where character data corresponding to codes 03h and
0Dh is specified as the break character in the ZRECEIVE instruction and the received
data is entered. It is assumed that the communication channel is already open.
10 DIM TBL1%(2),TBL2%(4),TBL3%(2)
20 TBL1%(0)=9600
30 TBL1%(1)=&H108
40 TBL1%(2)=&H1
50 ZOPEN #2,TBL1%( )
: ‘ Opens the channel
60 TBL2%(0)=22
: ‘ Specifies to set the break character
70 TBL2%(1)=2
: ‘ Specifies the number of break characters (2 types)
80 TBL2%(2)=&H30D
: ‘ Specifies the break characters (&H03 and &H0D data)
90 ZCNTL #2,0,TBL2%( )
: ‘ Executes the break character setting
100 RD$=SPACE$(100)
: ‘ Stores a dummy
110 TBL3%(0)=100
: ‘ Number of requested bytes (100 byte)
120 TBL3%(2)=200
: ‘ Timeout value (20 seconds)
130 ZRECEIVE #2,0,TBL3%( ),RD$
: ‘ Executes the reception operation
In this case, the amount of received data (number of bytes) returned to the BASIC
program is returned to TBL%(1). Also, when the break character is detected by the
system program, the detected break character is included in the last data received
within RVBUF$.
(Example)
indicates a space (20
H
) and
C
R
the carriage return (0D
H
) code.
When the reception data “0123456
C
R
” is returned:
The content of RVBUF$ prior to the
execution of the ZRECEIVE instruction
• • •
“
• • • •
”
(for 100 bytes)
The content of RVBUF$ after the
execution of the ZRECEIVE instruction
• • •
“0123456
C
R
• •
” (for 100 bytes)
RVBUF$
99
0
1
2
3
4
5
6
7
8
• •
•
20
H
20
H
30
H
31
H
32
H
33
H
34
H
35
H
Data prior to reception
is stored as is.
The value 8 is returned
in TBL%(1).
After reception
Prior to reception
20
H
20
H
20
H
20
H
20
H
20
H
20
H
20
H
20
H
20
H
0D
H
36
H
Memory addresses for
data stored in RVBUF$
(offset address)
• •
•
• •
•