24    Sequoia Series 
3.3.1  Serial Communication Test Program 
The following sample program written in  GW-BASIC can  be  used to check  communication to the 
Sequoia Series power source over the RS232C serial interface. 
'California Instruments Sequoia Series RS232C Communication Demo Program 
'(c) 1995-2002 Copyright California Instruments, All Rights Reserved 
'This program is for demonstration purposes only and is not to be 
'used for any commercial application 
'================================================================ 
'OPEN COM2. Replace with COM1, COM3 or COM4 for Com port used 
'The input and output buffers are set to 2K each although 
'this is not required for most operations. 
OPEN "COM2:9600,n,8,1,BIN,TB2048,RB2048" FOR RANDOM AS #1 
CLS 
PRINT "**** INTERACTIVE MODE ****" 
'Enter and endless loop to accept user entered commands 
DO 
        INPUT "Enter AC Source Command ('quit' to exit)--> ", cmd$ 
        IF cmd$ <> "QUIT" AND cmd$ <> "quit" THEN 
                PRINT #1, cmd$ + CHR$(10); 
                IF INSTR(cmd$, "?") THEN 
                        PRINT #1, CHR$(4); 
                        LINE INPUT #1, response$ 
                        PRINT response$ 
                END IF 
                'Check for Errors after each command is issued 
                PRINT #1, "*ESR?" + CHR$(10); 
                PRINT #1, CHR$(4); 
                LINE INPUT #1, esr$ 
                esr% = VAL(esr$) AND 60 
                IF esr% AND 4 THEN 
                  PRINT "*** Query Error Reported by AC Source ***" 
                END IF 
                IF esr% AND 8 THEN 
                  PRINT "*** Instrument Dependent Error Reported by AC Source ***" 
                END IF 
                IF esr% AND 16 THEN 
                  PRINT "*** Command Execution Error Reported by AC Source ***" 
                END IF 
                IF esr% AND 32 THEN 
                  PRINT "*** Command Syntax Error Reported by AC Source ***" 
                END IF 
        END IF 
LOOP UNTIL cmd$ = "QUIT" OR cmd$ = "quit" 
'Close COM port on exit 
CLOSE #1 
END