Programming instructions

76
Intermec Fingerprint 6.13 – Programmer's Guide
7. INPUT TO FINGERPRINT, cont'd.
8. Background
Communication, cont'd.
Continued!
After adding a few lines to print the content of the buffer (line
1050) and to create a loop that waits from input from the host (line
90), the entire example will look like this. You can run the
example by typing RUN and pressing Enter on the keyboard of
the host. Then enter different characters and see what happens,
comparing with the start character, stop character, ignore character,
attention string, and max. number of characters parameters in the
COMSET statement.
NEW
10 COM ERROR 1 ON
20 A$="Max. number of char. received"
30 B$="End char. received"
40 C$="Attn. string received"
50 D$="Communication error"
60 COMSET 1, "A",CHR$(90),"#","BREAK",20
70 ON COMSET 1 GOSUB 1000
80 COMSET 1 ON
90 IF QDATA$="" THEN GOTO 90
100 END
1000 QDATA$=COMBUF$(1)
1010 IF COMSTAT(1) AND 2 THEN PRINT A$
1020 IF COMSTAT(1) AND 4 THEN PRINT B$
1030 IF COMSTAT(1) AND 8 THEN PRINT C$
1040 IF COMSTAT(1) AND 32 THEN PRINT D$
1050 PRINT QDATA$
1060 RETURN
RUN
Two instructions facilitate the use of background communication:
LOC (Locate)
The LOC function returns the status of the receive or transmitter
buffers in an OPENed communication channel:
- If the channel is OPENed for INPUT, the remaining number of
characters (bytes) to be read from the receive buffer is returned.
- If the channel is OPENed for OUTPUT, the remaining free space
(bytes) in the transmitter buffer is returned.
The number of bytes includes characters that will be MAPped as
NULL.
This example reads the number of bytes which remains to be
received from the receiver buffer of "uart2:":
10 OPEN "uart2:" FOR INPUT AS #2
20 A%=LOC(2)
30 PRINT A%
...
...