beautypg.com

Rpbasic-52 programming guide, Appendix b - modem example program – Remote Processing BASIC 52 User Manual

Page 150

background image

RPBASIC-52 PROGRAMMING GUIDE

B-1

APPENDIX B - Modem example program

F i le : M O D E M .B A S

rem Modem communication program
rem Based around BASIC-52 software for RPC-320, 330

rem General operation.
rem This program is designed as a receiver. Dialing out from
rem a modem is simply a matter of sending a ATDT
rem command and responding appropriately to whatever is dialing.
rem Additional cycles (explained later) must be added to handle this

rem Receiving is a matter of going through a series of steps, or
rem cycles. The first cycle is to detect Ringing message. Then
rem Connect . After that, a password is entered.
rem Line 2300 sets the password. After 3 fails, it hangs up.

rem Commands are then processed. Processing is done as part of
rem the main loop rather than in the interrupt.

rem Commands are processed at line 2400. At this point the card
rem could be treated as a network, processing commands. A more
rem sophisticated command handler is in the RS-485 demo program. (Appendix A)

Rem ONTICK acts as a communication timer. Should there be a
rem period of inactivity while the modem is on line, it issues a
rem hang up command to the modem. Timeout for this example is
rem 10 seconds. It is controlled by the variable CTIM

rem The program is designed so that on a communication problem,
rem it will hang up and reset the modem. The OK string from the
rem modem is treated as a "ready to receive" indication from the
rem modem. If no OK is received, it will go through a hang-up-
rem reset process every 10 seconds until it receives one.
rem The NOKFL variable is set to 1 if no OK message is received.
rem This is read by the main loop since what to do with an inoperative
rem modem is application dependent.

rem If a NO CARRIER message is received from the modem after connecting,
rem the modem will be reset. If you expect to ever send this string over,
rem modify the program at lines 1500+ else the modem will be reset.

rem Some modem messages such as NO DIALTONE, BUSY, and NO ANSWER are not
rem processed since these are outgoing dependent. However, they can be
rem processed by adding CYCLEs.

rem To run this program "as is", you should have 2 PC's available.
rem This program has DEBUGging print statements throughout.
rem They may be removed as required.
rem One is connected to the card, the other to a phone line through
rem a modem. Configure the modem per the RPBASIC software manual.
rem Connect a modem to an RPC-320, 330,
rem or other software compatible card (one that recognizes ON COM$)
rem to COM 1. Don't forget to put a null modem adapter between the
rem modem and card. Connect a PC or other such device to COM 0.
rem Download this program.

rem Connect the modem to a phone line. Run your other PC's modem
rem program. Run this program on the RPC card. You will see initialization
rem messages and status displayed. You should see RD and SD lights blinking
rem on the external modem. What you are looking for is

rem cycle = 0 atim = 0

rem on the bottom of the screen. Dial up the RPC card from the other PC.
rem You should see a progression of messages such as RING, CONNECT
rem and the CYCLE count will increase. Pay attention to your dial up
rem PC. You should see a short sign on message and a prompt for a