170 PRINT #1,"CHN" 'Send command to read a channel.
190 GOSUB 2000 'Get response.
200 IF ERRCODE% <> 0 THEN PRINT "No response.", : GOTO 250
210 PRINT RESPONSE$
250 PRINT
260 GOTO 134 'Do it again.
270 '-----------------------------------------------------------
1000 'These subroutines assume that the following variables have
1010 'been defined in the application program's main module:
1020 '
1030 ' TIMEOUT - A single-precision floating-point variable
1040 ' equal to the timeout value (in seconds) to be
1050 ' used on reads.
1060 ' TERM$ - A string equal to a carriage return
1070 '
1080 'The GOSUB 2000 and GOSUB 3000 routines return the
1090 'variable ERRCODE% which indicates an error condition
1100 'was detected during communication with the
1110 'network.
1120 'The error codes are as follows:
1130 '
1140 ' ERRCODE% = 0 Successful completion of subroutine call.
1150 ' 1 Instrument responded with 'NAK'.
1160 ' 2 Instrument did not successfully open after three
tries.
1170 ' 3 Timeout error -- Instrument did not respond.
1180 '
1190 '------------------------------------------------------
2000 'Routine to read a response from a command.
2010 RESPONSE$="" : CHARIN$=""
2020 ELAPSED=0 : ERRCODE%=0
2030 OLDTIME=TIMER
2040 WHILE (ELAPSED < TIMEOUT%) AND (CHARIN$ <> TERM$)
2050 WHILE (LOC(1) <> 0) AND (CHARIN$ <> TERM$)
2060 CHARIN$=INPUT$(1,1)
2070 IF CHARIN$ <> TERM$ THEN RESPONSE$=RESPONSE$+CHARIN$
2080 WEND
2090 ELAPSED=TIMER-OLDTIME
2100 IF ELAPSED < 0 THEN ELAPSED=ELAPSED+86400!
2110 WEND
2120 IF CHARIN$ <> TERM$ THEN ERRCODE%=3
2130 ELSE IF RESPONSE$ = "NAK" THEN ERRCODE%=1
2140 RETURN
2150 '
2160 '------------------------------------------------------
3000 'Routine to open a node on a network.
3010 TRIES%=0 : ERRCODE%=-1
3020 WHILE (TRIES% < 3) AND ERRCODE%
3030 PRINT #1,"OPN"+MID$(STR$(NODE%),2) : GOSUB 2000
3040 TRIES%=TRIES%+1
3050 WEND
3060 IF ERRCODE% = 3 THEN ERRCODE%=2
3070 RETURN
3080 '
3090 '------------------------------------------------------
D.2
D
NETWORKING GUIDELINES
NETWORKING GUIDELINES