Beruflich Dokumente
Kultur Dokumente
by ROY TARANTINO
How practical is it to use the airwaves as a communications medium for embedded systems? The
author describes his experience
developing a packet radio protocol
stack for a single-board computer
and the issues involved with integrating wireless communications
into embedded systems.
TR2
T
38 EMBEDDED SYSTEMS PROGRAMMING
FEBRUARY 1996
Under Mobitex,
packet switching
is a very efficient
way to transfer
data. In packet
switching, no endto-end connection
is established.
countries around the world. Standardization of all Mobitex networks
and compatibility of network features
is ensured by the Mobitex Operators
Association (MOA). MOA is an independent organization that publishes an
open standard document known as the
Mobitex Interface Specification. The
standard defines the following specifications in great detail:
Wireless
MOBITEX INTERFACE TECHNOLOGY
AM Mobile Data has developed Mobitex interface software designed to make it relatively easy to build wireless applications. The software is written in ANSI
C and designed to be ported to many
hardware platforms including embedded microcontrollers. Highly modular,
the interface software allows Mobitex
configurations ranging from full functionality to the minimal subset necessary for network communications.
Two levels of configurability are provided. Compiler time constants eliminate code and data during the compile
phase, and because functional areas are
partitioned into separate source code
files, memory requirements are further
reduced by linking in only necessary
functions.
The interface software is made up of
three modules: an operating system
interface that contains interfaces to
system resources, a MASC module
that contains the MASC protocol
implementation, and an MPAK that
implements the MPAK network protocol. All three modules work together to
present a complete Mobitex interface
to application designers without placing high demands on system resources.
Each module is described in the following and illustrated in Figure 2:
FEBRUARY 1996
FIGURE 1
A basic Mobitex system.
Regional
Switch
(MHX)
Local
Switch
(MQX)
Local
Switch
(MQX)
Subnet
Subnet
Local
Switch
(MQX)
Subnet
Wireless Communication
intervals to poll for a certain event or
perform
some
housekeeping.
Therefore, unlike the OSI seven-layer
model, a higher layer process using the
Mobitex interface software is not limited to the services of the next lower
layer. It can make use of interfaces that
reside in all three lower layer modules.
Wireless Application
MPAK Module
MASC Module
FEBRUARY 1996
typedef struct
{
FSM_ID
MachID;
/* ID number of machine */
VOID_FPTR MachEntry;
/* Address of machine entry function */
} MACHINE_ENT;
A machine can register with the dispatcher by providing a machine entry
function, a machine ID, and an initial
state. The event queuing function and
dispatcher is implemented by the following code:
/*
Queue an event for machine execution.
*/
RetCode EventDefer(FSM_ID MachID, ushort
event, void *param)
{
MACHINE_ENT *LookupMachine(FSM_ID);
MACHINE_ENT *Machine =
LookupMachine(MachID);
DEFERRED_EVENT DeferredEvent;
RetCode AppendList( LIST list, void
*ListElem);
if (Machine == NULL_MACHINE)
{
/* Not found, return error */
return (MACHINE_NOT_FOUND);
}
DeferredEvent.Machine = Machine;
DeferredEvent.Event = event;
DeferredEvent.Param = param;
return (AppendList(DeferredEventList,
&DeferredEvent);
}
/*
Execute the next event on the deferred
event queue.
*/
void DispatchEvent()
{
DEFERRED_EVENT DeferredEvent
MACHINE_ENT *Machine;
DeferredEvent = (DEFERRED_EVENT *)
ListRemoveHead(DeferredEventList);
if (DeferredEvent != NULL_EVENT)
{
FEBRUARY 1996 EMBEDDED SYSTEMS PROGRAMMING 45
Wireless Communication
Machine = DeferredEvent->Machine;
Machine->MachEntry(DeferredEvent->Event,
DeferredEvent->Param);
MemFree(DeferredEvent);
}
else
{
/* No work to do. */
}
}
The EventDispatch function can be
called during idle time and will perform a unit of work. Entry functions
are implemented by queuing an event
for each request and then returning an
in-progress indicator to the caller.
Action functions are called by the
machine entry functions and carry out
the state transitions necessary to complete the request. For example, if the
user requests coverage status from the
MASC module, the coverage status
entry function is called, which will
queue the request and then return.
Eventually the action function associated with coverage status is called by
the MASC machine. The action function will then construct the necessary
command and send it to the radio
modem. When the radio modem
responds, the response is queued by the
serial port interrupt handler in the
operating system interface module.
The MASC machine will then complete the request by taking the response
and passing it back to the original
requester by calling the requesters
callback or completion function.
The Mobitex interface software has
minimal impact on the system CPU
because the majority of the protocol
work is triggered by the dispatch function, which is completely controlled by
the application. Both the serial communications and timer interrupt handlers perform minimal work queuing
requests to the deferred event queue.
The queuing operation involves only a
single address write to append the
request. The serial communications
interrupt handler must buffer every
character that comes into the serial port
and call the OS interface function to
/*
Mobitex Interface Software Character
Interrupt Routine
FEBRUARY 1996
FIGURE 3
The service layer framework.
User Layer
User Functions
Function calls
Callbacks
Indications
Entry Functions
(Exposed Interface)
Queued
Event
Queued
Event
Queued
Event
Wireless Communication
LISTING 1
Simple Mobitex Interface Software
Test Program.
*/
Wait for a packet, when one comes in reflect it
back to the sender.
*/
#include <stdio.h>
#include <string.h>
#include "mpakuser.h"
int my_state=0;
MPAK_STATS StatsData;
MACH_HNDL hMachine;
char mpakbuf[512];
main()
{
RQST_ID Request;
FEBRUARY 1996
LISTING 1 (CONTINUED)
mpakbuf[2] = mpakbuf[5];
RQST_ID RqstID, void *data, LEN_TYPE
length)
{
printf("main: in MyCompletionFunctions ");
switch(IndType)
{
case MPAK_INIT_CPLT:
printf("status=%s\n",
(Status==SUCCESS)?"SUCCESS":"FAILED");
my_state=MPAK_INIT_CPLT;
break;
case MPAK_ENABLE_CPLT:
printf("status=%s\n",
(Status==SUCCESS)?"SUCCESS":"FAILED");
my_state=MPAK_ENABLE_CPLT;
break;
case MPAK_DATA_REG_CPLT:
printf("status=%s\n",
(Status==SUCCESS)?"SUCCESS":"FAILED");
my_state=MPAK_DATA_REG_CPLT;
break;
case MPAK_SEND_CPLT:
printf("status=%s\n",
(Status==SUCCESS)?"SUCCESS":"FAILED");
my_state=MPAK_SEND_CPLT;
break;
}
}
Wireless
account that wireless links are constantly changing. In a vehicle mounted
system, the mobile could go in and out
of signal coverage as the vehicle
moves across the cell. Intelligent send
and receive retry algorithms should be
used, which take into account the coverage state, and should not attempt a
retry until the signal is strong enough
to ensure good reception or transmission. Feedback should be given to the
user. In some cases users should be
included in the retry decision. Users
will have a good idea of the coverage
at a given location, and the combination battery level and signal strength
can be used to conserve or optimize
power usage. A good test for wireless
applications is to stress the application
at a fringe area of coverage to see how
it reacts to the transitions. Finally,
applications should always give the
user the capability to silence the radio
at any time to prevent radio interference with other more critical systems
such as medical devices or construction site equipment.
AFTERTHOUGHTS
ireless data communications
technology offers the embedded system designer the
capability to add sophisticated communications functions without the need
for wires or cabling. The technology is
now widely accepted. Reliable network infrastructures are in place and
development tools are available.
FEBRUARY 1996