Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual
Page 151

RPBASIC-52 PROGRAMMING GUIDE
B-2
rem password. Enter 'password'. Use lower case. The password is
rem set at line 2300.
rem You are then prompted for a command. Commands for this demo are
rem prefixed with '>03'. The command is a number following the '3'.
rem To return the current analog reading on channel 0, type '>030'
rem You will probably get 0 if there is no voltage on channel 0.
rem To return the status at line 0, type '>031'. You will probably
rem get a 1. A '>032' will disconnect from the line.
rem If you do nothing, the modem will reset by the time atim = 9
rem as printed on the screen. When that happens, the modem disconnects
rem and resets.
rem Other things to consider.
rem If you are going to be sending out data for long periods of time,
rem be sure to change the variable ctim or reset atim periodically.
rem This program is designed to hang up if there is inactivity for a period
rem of time. Default is 10 seconds.
rem CYCLE 4 is the hang up/reset modem cycle. When something sets this cycle
rem in motion, nothing in this program can get it out. CYCLE 4 starts by
rem assuming that nothing is being transmitted out. It does wait a period of
rem time to ensure the time dependent escape sequence gets recognized.
rem A potential problem is in downloading information. Running at 1200 baud,
rem characters are sent out at about 120 characters/second. If you are sending
rem out lots of data, chances are the serial buffer in the card will get full.
rem At this baud rate, it will take about 2 seconds to empty. If you go into
rem CYCLE 4 right after a data dump, the escape sequence will not be recognized
rem immediately. Since CYCLE 4 keeps trying to reset the modem, it will
rem eventually reset it. In the mean time, you may get "strange" data on
rem the receiving end.
rem This program was moderately tested. It recovers from no connects,
rem disconnects, and modem power off/on conditions fairly well. Keep
rem in mind each modem tends to operate a little differently and some
rem adjustments might have to be made. The biggest problem we had was
rem in "dead" times. Manufactures claim they need 1 second of dead time
rem before sending the escape sequence, but we found one needed more. Also
rem you may need to pause a little longer after getting the CONNECT message
rem before sending out a sign on message.
rem We used USR, Practical Peripherals, and "no name" modems.
rem variable definition
rem cycle = communication cycle counter
rem mcycl = main loop multi tasking cycle
rem flag(n) = main task dispatcher flag
rem atim = actual time since last communication (in seconds)
rem ctim = commanded time for timout
rem htim = hang up/reset timer
rem $(0) = input string from com 1 buffer
rem $(1) = working search string in com 1 interrupt routine
rem $(2) = NO CARRIER string constant
rem cia = Communication Interrupt variable A - working variable
rem passw = pass word tries
rem okflg = flag to indicate OK was received 1 = got it
rem nokfl = flag to indicate OK was NOT received 1 = not got it
rem The main loop looks at nokfl and resets it. Reason being is
rem modem may be bad, not powered, or not connected.
rem Application requirements dictate what to do in case of a bad
rem modem. This flag is reset by the main loop. This program
rem is set up to continuously try to reset the modem.
rem nocfg = no carrier flag 1 = "NO CARRIER" string found
rem Variable root tim was used because time is a key word.
rem initialize strings, arrays, interrupts
10 config baud 1,5,0 :rem 1200 baud for this example