G Mode Functions
Chapter 8
GPIB-232CT User Manual
8-18
© National Instruments Corp.
Examples:
1.
10 REM Tell GPIB-232CT to send us numeric
20 REM status.
30 WRT$="stat n"+CHR$(13)
40
CALL
IBWRT(GPIB232%,WRT$)
50 REM Now read the status from the
60
REM
GPIB-232CT.
70 STATUS$=SPACE$(10) : GPIBERR$=SPACE$(10)
80 SPERR$=SPACE$(10) : COUNT$=SPACE$(10)
90
CALL
IBRD(GPIB232%,STATUS$)
100 REM Read up to 10 bytes of status.
110 REM The GPIB-232CT returns 4 pieces of
120 REM status, one for each IBRD. We are set
130 REM up to terminate read on linefeed, which
140 REM is what terminates each piece of status.
150 STATUS% = VAL(STATUS$)
160 CALL IBRD(GPIB232%,GPIBERR$) 'Read GPIB-error.
170 CALL IBRD(GPIB232%,SPERR$)
'Read serial-error.
180 CALL IBRD(GPIB232%,COUNT$)
'Read count.
190 REM Call error routine at 500 if error occurred.
200 IF STATUS% < 0 THEN GOTO 500
...
500 REM Print GPIB-error, and serial-error
510 REM values to determine what errors occurred.
520 PRINT "GPIB-error = ";GPIBERR$
530 PRINT "serial-error = ";SPERR$
540
STOP
2.
10 REM Turn on continuous status reporting,
20 REM in numeric format.
30 WRT$="stat c n"
40
CALL
IBWRT(GPIB232%,WRT$)
50 REM If we have 3 bytes in the serial port
60 REM buffer, a typical response would be:
70 REM 262<CR><LF>0<CR><LF>0<CR><LF>3<CR><LF>
80 REM Read the GPIB-232CT status; read 30
90 REM bytes or until EOI is received.
100
RD$=SPACE$(30)
110
CALL
IBRD(GPIB232%,RD$)
120 REM Print the status information.
130 PRINT "GPIB-232CT status is: ";RD$