'------------------------------------------------------------------------------

'------------------------------------------------------------------------------

'

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 4071 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 4071 is attached to the serial port --------------

' If we send the 4071 a control E character, it will respond with a control C. ' We use this feature to see if a 4071 is attached.

' If a 4071 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 4071, 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 4071

PRINT "Connect the 4071 to the serial port and power the 4071"

ConnectLoop:

 

PRINT #1, CHR$(5);

' Print a control E to 4071 (ASCII char 5)

'Wait for the 4071 to give us some characters. When they arrive, put

'then into the string a$

GOSUB GetResponse1

' Wait for and get response from 4071 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 4071? IF INSTR(a$, CHR$(3)) THEN GOTO GotSG100

GOTO ConnectLoop

GotSG100:

73

BK Precision 4071 User Manual Rev.2.2

Page 78
Image 78
B&K 4071 user manual Cls