Chapter 4 Remote Operation and Programming
Batch Processing for the Program Commands
Operating and Programming Manual 63
44 PRINT Return$ ! control voltage.
45 !
46 END
47 !
48 !=======================================================================
49 !
50 DEF FNConfig_ser_port$(INTEGER Sel_code,Baud)
51 ! This function sets up the serial interface at the designated select
52 ! code.
53 ! The configuration is 8 data-bits, 1 stop-bit, and no parity.
54 ! The 5071a requires the interface to assert the DTR line, or to
55 ! leave it un-connected. There is no hardware handshake.
56 ! The returned string reports the details of the set-up.
57 ! If the set-up fails, an error message is returned.
58 !
59 ON ERROR GOTO Err_trap
60 !
61 CONTROL Sel_code,0;1 ! Reset interface
62 CONTROL Sel_code,3;Baud! ! Baud rate
63 CONTROL Sel_code,4;3! ! 8 bits, no parity
64 CONTROL Sel_code,5;1! ! Set DTR
65 CONTROL Sel_code,12;176! ! HDSK disabled
66 !
67 RETURN "Serial interface at Select Code "&VAL$(Sel_code)&" set up: "&VAL$(Baud)&", 8, None"
68 !
69 Err_trap: !
70 RETURN ERRM$
71 FNEND
72 !
73 !========================================================================
74 !
75 DEF FNTalker$(Output$)
76 ! This function sends a command or query to the 5071A then retrieves
77 ! the 5071A response.
78 !
79 COM /Io/Prompt$[4],Term$[1],@Ser_in,@Ser_out,Timeout,INTEGER Com_port
80 !
81 DIM Input$[2048],A$[1],Reply$[2048]
82 !
83 ON DELAY Timeout,15 GOTO Hang ! 15 is highest priority.
84 !
85 Chars_in_queue=READIO(Com_port,31)
86 !
87 WHILE Chars_in_queue ! Empty @Ser_in input queue.
88 ENTER @Ser_in USING "#,B";Byte ! ! Enter one byte (character).
89 Chars_in_queue=READIO(Com_port,31)
90 END WHILE
91 !
92 OUTPUT @Ser_out;Output$
93 WAIT .05 ! Wait 50 msec for 5071A
94 ! ! to begin to respond.
95 WHILE NOT Complete
96 Chars_in_queue=READIO(Com_port,31)
97 IF Chars_in_queue THEN
98 ENTER @Ser_in USING "#,A";A$ ! Enter one character.
99 Input$=Input$&A$ ! Add character to string.
100 IF A$=Term$ THEN ! and check for termination
101 WHILE NOT Complete ! character. When termination
102 Chars_in_queue=READIO(Com_port,31) ! appears, one more character
103 IF Chars_in_queue THEN ! is unloaded and added to
104 ENTER @Ser_in USING "#,A";A$ ! the string. It is the
105 Reply$=Input$&A$ ! trailing space.