beautypg.com

Comtrol API (6508) for the MS-DOS User Manual

Page 15

background image

Developing Applications

15

Developing Applications

2.8.2.7. Detection Enable Parameter

The detection enable parameter is used by aaOpen() and aaReconfigure() to set
which events are detected by the

API

.

If a detection enable flag is set, an event function within the application is
dispatched when that event is detected. This assumes that the application has
installed the event function. See Subsection 2.12 for information about event
functions.
You can assign any combination of the flags shown in
Table 2-10 to the detection enable parameter. The detection enable parameter
is declared as follows:

unsigned int DetectEn;

2.8.2.8. Modem Control Parameter

The modem control parameter is used by aaOpen() to determine the initial
state of the modem control outputs. If a flag is set, the modem control line is
turned

ON

; otherwise it is

OFF

.

It is also used by aaClose() to determine which modem control outputs must be
cleared. If a flag is set, that modem control line is turned

OFF

; otherwise it is

not changed.
The modem control output flags are given in Table 2-11. The modem control
parameter is declared as follows:

unsigned ModemCtl;

2.9. Writing Serial Data

After a device is open, serial data can be written to it using aaWrite(). The
number of data bytes from previous aaWrite() calls that are still awaiting
transmission can be obtained with aaGetTxCount().

2.10. Exiting the Application

You must call aaExit() before exiting an application. This does final cleanup,
including removing the interrupt service routine (

ISR

) used by the

API

.

2.11. Reading Serial Data

After a device is open serial data can be read from it using aaRead(). The
number of receive data bytes that are buffered by the device can be obtained
with aaGetRxCount().
Using aaRead() by itself does not return any receive error information. If error
information is needed, you can determine if there are any errors in the device’s
receive buffer by calling aaGetRxStatus(). If errors exist, you can obtain the
error status of each receive data byte by reading the data with
aaReadWithStatus().

2.12. Installing and Detecting Events

When the controller needs to notify the system that something important has
occurred, it generates an interrupt and causes an event function to execute on
the system.
Event functions tell you what has happened and provide the appropriate
information for that event, which you can then process as needed.
The following receive events can occur on the system:

Modem change event, one of the modem lines has changed for a serial
device.

Receive data event, data has been received on a serial device.

Periodic event, occurs 274 times per second.

You need a way to tie your application to these events. This is accomplished by
calling the aaInstallxxxEvent functions. By using an aaInstallxxxEvent function,

COM_FLOW_OS

Enable output software flow control

COM_FLOW_OH

Enable output hardware flow control
using

CTS

COM_FLOW_OXANY

Enable restart output on any Rx
character

Table 2-10. Detection Enable Flags

Flag

Meaning When Flag Set

COM_DEN_NONE

No event detection enabled

COM_DEN_MDM

Enable modem control
change detection

COM_DEN_RDA

Enable receive data available
detection

Table 2-9. Flow Control Flags (Continued)

Flag

Meaning When Flag Set

Table 2-11. Modem Control Output Flags

Flag

Modem Control Line

COM_MDM_RTS

Request to send

COM_MDM_DTR

Data terminal ready