beautypg.com

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

Page 14

background image

RPBASIC-52 PROGRAMMING GUIDE

1-11

0

Wait for "RING" message. Modem
auto answers.

1

Look for "CONNE CT".

2

Get password. If invalid, prompt for
password again.

3

Send succe ssful log in me ssage .
Prompt for comm and and process
t he m .

4

Take modem off line and reset

5

Delay for a few seconds and send sign
on message.

The actual program is more complicated than the
steps indicate. Timeouts are used to disconnect the
modem when there is inactivity. Three failed
passw ord atte mpts takes t he m odem off line.
Ring ing bu t no co nnec t takes the m odem off line.
Superfluous 's are ignored.

Activity timeout is set for 10 seconds. The
ONTICK routine checks for activity every second
when the program cycle advances to step 1 and
beyon d. ON TIC K cou ld be fa ster if it is nece ssary.
Keep in mind that ONTICK interrupts have the
highest priority. Keep tick interrupt processing
times short and as infrequent as possible. Frequent
and/or long processing times take away from other
program times.

ON COM $ interrupt uses a program cycle pointer
(variable CYCLE) to direct the next activity on an
interrupt. When a message is received, an interrupt
is generated. Processing the message is handled by
the ap propria te routi ne poi nted to by CY CLE . A
sequence is simply ignored and treated as a
non-event.

After the password is accepted, the main purpose of
the application takes over. There are many
scenarios, or situations, possible:

1.

The c omp uter is u sed for d ata log ging.
Dialing in merely dumps data.

2.

The computer is used for control. A dial up
is for new instructions or parameters.

3.

Some combination of data logging and
control.

4.

A computer will dial up and query and/or
issue new instructions.

5.

A person using a terminal will dial up the
control card and query and/or issue new
instructions.

6.

A com puter and/or person at a terminal w ill
dial up and query and/or issue new

instructions.

7.

A new program is downloaded to the card.

The number of possible applications is much too
complex to even begin showing code.

Some a pplications use a person at a term inal to
remotely query the card. In this situation, it is nice
to return a characte r as soon as it is typed in. T his
can be done by setting the users terminal to local
echo. However, you don't know if the card received
what you send. The remote card can echo back
characters as they are sent. To do this requires a
program change. ON COM $ must either be disabled
or changed to generate an interrupt on each character
input. If ON C OM$ is disabled, then the m ain
program has to be structured so it can process
incom ing ch aracte rs imm ediate ly.

If ON COM$ generates an interrupt on each
character, then the incoming data rate should be
relatively slow (1 c haracter every 5 0 ms). Note th is
is not th e baud rate. Th e baud rate ca n still be 9600.
It just should not get characters more than 20
times/second. For hand typing situations, this is just
fine.

When another computer is talking to the card,
immediate echo may not be necessary. Instead, the
incoming message can be echo ed back w hen a
is received (or when ON COM$ generates an
interrupt). The cycles would merely increase based
on the command. In some ways, it becomes like a
RS-485 n etwork desc ribed above. A comm and is
received, parsed, and processed.

Scenario 7 requires some cautionary notes. It is not
unusu al to do wnlo ad pro gram s throug h a m odem .
There is no difference between a modem down load
a n d on e d ir e ct l y c o n ne c te d to a P C . T h e U I a n d U O
commands m ust be set to 1 when using COM 1 and
before going into the command mode (executing an
END or STOP statement in th e program ).

A problem arises when communication is lost for
some reason. While the RPC cards have a watch
dog timer, they are not enabled during command
mode (T his is true of the RP C-320 and RPC -330.)
When comm unication is lost, usually a ll that is
required is to redial the modem, assuming it has
been set to auto answer. If comm unication is lost
due to som e external force (ce ll phone or netw ork
failure ), the ca rd will just sit th ere an d not ru n.
When the application is mission critical, an external