54
2060 ‘
3000 ‘Enter.User.Commands: Get and interpret the user’s commands
3010 WHILE (1) ‘Get and process user input until Q or q is input.
3020 RS232OUT$ = “ “ ‘Clear RS232out$ string
3030 LINE INPUT RS232OUT$ ‘Get the user input
3040 IF RS232OUT$ = “Q” OR RS232OUT$ = “q” THEN RETURN ELSE GOSUB 4000
3050 ‘Assume strings ending with “?” are queries
3060 IF INSTR(RS232OUT$, “?”) = 0 THEN GOTO 3090
3070 GOSUB 5000
3080 PRINT RS232IN$;
3090 END IF
3100 WEND
3110 RETURN
3120 ‘
4000 ‘Write.RS232.String: Write the string RS232OUT$ to the RS-232 port
4010 PRINT #1, RS232OUT$ ‘PRINT # appends <CR><LF> to the string
4020 RETURN
4030 ‘
5000 ‘ Read.RS232.String : Read a string from the 1830-C RS-232 port
5010 ‘ Characters are read one at a time until a <LF> character is
5020 ‘ read or 2 seconds elapse between consecutive character reads.
5030 ‘ At end of routine the string read or an error is in RS232IN$.
5040 BUFFER$ = CHR$(0) ‘Initialize BUFFER$ to NULL character
5050 RS232IN$ = “”
5060 TIMEOUT.ERROR% = 0 ‘Initiate to no timeout error
5070 ON TIMER(1) GOSUB 7000 ‘Set timer for a 1 second time out
5080 TIMER ON ‘Turn on timer
5090 ‘While port doesn’t timeout and string delimiter <LF> not
5100 ‘read,continue trying to read input COM port.
5110 WHILE TIMEOUT.ERROR% = 0 AND BUFFER$ <> CHR$ (10)
5120 IF LOC(1) = 0 THEN GOTO 5170
5130 TIMER OFF
5140 BUFFER$ = INPUT$(1, #1)
5150 RS232IN$ = RS232IN$ + BUFFER$
5160 TIMER ON
5170 END IF
5180 WEND
5190 TIMER OFF
5200 IF TIMEOUT.ERROR% = 1 THEN RS232IN$ = “Timed out when reading RS-232 port. “ +
CHR$(13)
5210 RETURN
5220 ‘
6000 ‘Turn.Echo.Off: Turns the echo mode off if it is enabled.
6010 RS232OUT$ = “E?”
6020 GOSUB 4000