BNC 630 User Manual
Page 84
![background image](/manuals/545983/84/background.png)
79
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
' Program Start
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
DECLARE SUB Delay (X%) ' Declare functions used below.
' (The Delay function waits x mS then returns)
DECLARE SUB Pause ()
' (The Pause fctn waits for a keypress then returns)
CLS ' Clear the screen
' Open serial port 1 for communication with the 630 with these parameters:
' Ignore the CD,CTS,DCD flow control lines
' Set a 5 sec maximum time-out for basic to open the port
' Set the receive buffer to 2K bytes
' Disable the RTS flow control line
' Set the transmit buffer to 1K bytes
' File access type is Random
' Set random access buffer size to 2K
OPEN "COM1:9600,n,8,1,CD0,CS0,DS0,OP5000,RB2048,RS,TB1024" FOR RANDOM AS #1 LEN = 2048
'----------- Make sure a 630 is attached to the serial port --------------
' If we send the 630 a control E character, it will respond with a control C.
' We use this feature to see if a 630 is attached.
' If a 630 cannot be found, wait until one is attached.
' User can abort the program at this point by pressing any key.
' When power is applied to the 630, it prints a menu to the serial port. We wish to
' disregard these characters, so flush them.
GOSUB FlushBuff1 ' Flush all received chars from buffer
' Tell the user to connect up a 630
PRINT "Connect the 630 to the serial port and power the 630"
ConnectLoop:
PRINT #1, CHR$(5); ' Print a control E to 630 (ASCII char 5)
' Wait for the 630 to give us some characters. When they arrive, put
' then into the string a$
GOSUB GetResponse1 ' Wait for and get response from 630 to a$
' Allow the user to exit the program by pressing a key.
IF INKEY$ <> "" THEN SYSTEM ' Exit on first terminal keypress
' Did we get a control C (ASCII char 3) from the 630?
IF INSTR(a$, CHR$(3)) THEN GOTO GotSG100
GOTO ConnectLoop
GotSG100: