User's Manual

5. Status Reporting
This program sets up the status reporting for Service Request on ‘Message Available’
and ‘Command’, ‘Execution’, or Query’ errors.
The program reads a command from the controller keyboard and sends it to the coun
-
ter, then it checks the status byte using Serial Poll. It determines the reason for Service
Request, and reads query responses and error messages.
50 CNTNAME$ = “DEV10"
60 CALL IBFIND (CNTNAME$, CNT%)
70 ‘
80 ‘
90 ‘ —— CLEAR STATUS ——
100 WRT$ = “*cls”
110 CALL IBWRT (CNT%, WRT$)
120 ‘
130 ‘ —— SET EVENT STATUS ENABLE ——
140 ‘ Enable Command Error, Execution Error and Query Error
150 WRT$ = “*ese 52"
160 CALL IBWRT (CNT%, WRT$)
170 ‘
180 ‘ —— SET SERVICE REQUEST ENABLE ——
190 ‘ Enable Service Request on Event Status and Message
Available
200 WRT$ = “*sre 48"
210 CALL IBWRT (CNT%, WRT$)
220 ‘
230 ‘ ======== MAIN LOOP =======================================
240 WHILE 1
250
260 ‘ —— ENTER COMMAND STRING AND SEND TO COUNTER ——
270 LINE INPUT “Enter command string (<CR> to end):”, CMD$
280 IF CMD$ = “” GOTO 760
290 CMD$ = CMD$
300 CALL IBWRT (CNT%, CMD$)
310 ‘ WAIT for execution
320 FOR I=1 TO 1000
330 CALL IBRSP (CNT%, SPR%)
340 IF SPR% AND 16 THEN GOTO 380
350 NEXT I
360
370 ‘ —— READ STATUS BYTE ——
380 IF SPR% <> 0 THEN PRINT “Status byte = ”; SPR%
390 ELSE GOTO 750
400
Programming Examples
GW-Basic for National Instruments PC-IIA, Setting Up the Interface 4-9