ProSoft Technology MVI69-ADM User Manual

Page 56

Advertising
background image

Understanding the MVI-ADM API

MVI-ADM ♦ 'C' Programmable

Developer's Guide

'C' Programmable Application Development Module

Page 56 of 342

ProSoft Technology, Inc.

February 20, 2013

MVI94

The MVI94 stores its configuration in flash memory, downloaded via the debug
port. The function

ReadCfg()

parses the file and qualifies the configuration data.

The configuration file uses headings in square brackets to define the sections.
Each item is parsed using the ADM flash file functions. The file is searched for a
configuration item. If a match is found, the value is saved into a variable.
Boundary checking is then performed on the data. An example of a configuration
item search follows:

ports[0].stopbits = ADM_FileGetInt("[Port]", "Stop Bits");
switch(ports[0].stopbits)
{
case 1:
ports[0].stopbits = STOPBITS1;
case 2:
ports[0].stopbits = STOPBITS2;
break;
default:
ports[0].CfgErr |= 0x0100;
ports[0].stopbits = STOPBITS1;
}

Here the file is being parsed for "Stop Bits" under the heading of [Port]. Refer to
the example code for a sample configuration file.

Because a pointer to a function is used by the ADM API to access this function,
the name can be anything the developer wishes. However, the function must
take the same arguments and the same return value.

3.4.7 Commdrv.c

The communication driver demonstrates how a simple driver might be written.
The driver is an ASCII slave that echoes the characters it receives back to the
host. The end of a new string is detected when an LF is received. The
communication driver is called for each application port on the module. The
following illustration shows information on the communication driver state
machine.

The state machine is entered at state -1. It waits there until data is detected in
the receive buffer. When data is present, the state machine advances to state 1.
It will remain in state 1 receiving data from the buffer until a line feed (LF) is
found. At this time the state advances to 2. The string will be saved to the
database and the state changes to 2000.

Advertising