110
5000
‘Read.RS232.String: Read a string from the 2835-C RS232 port.
5010
‘Characters are read one at a time until a <LF> character is
5020
‘read or 8 seconds elapse between consecutive character reads.
5030
‘At the end of the routine the string read 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(8) GOSUB 6000
‘Set timer for a 1 second time out
5080
TIMER ON ‘Turn on timer
5090
‘While port doesn’t timeout and string deliminator <LF> not
5100
‘read, continue trying to read input on 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
‘
5180
WEND
5190
TIMER OFF
5200
IF TIMEOUT.ERROR% = 0
THEN GOTO 5230
5210
PRINT “Timed out when reading RS-232 port.”
5220
TIMEOUT.ERROR% = 0
5230
‘
5240
PRINT RS232IN$;
5250
‘
5260
RETURN
5270
‘
6000
‘timeout: Set TIMEOUT.ERROR% flag. Called if t seconds, as
6010
‘defined by ON TIMER(t), in the Read.RS232.String, has elapsed
6020
‘between TIMER ON AND TIMER OFF.
6030
TIMEOUT.ERROR% = 1
6040
RETURN
10000
END ‘End of Program Listing
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com