Direct Interface Specifications

Cascade Driver for Hilscher Fieldbus CIF Cards: Version 4.1
Prev |  | Next

# Chapter 4. Direct Interface Specifications

This section describes an interface approach that by-passes the API. This lets you tailor the interaction with the driver to suit specific requirements and maximize performance. The user is responsible for assembling a message as specified in this section, performing a QNX synchronous `Send`, and interpreting the results.

Like the API, this interface supports ASCII commands and binary data block transfers. You will effectively be implementing code similar to that contained in the `DR_ApReadBlock` and `DR_ApWriteBlock` API calls, but have the opportunity to streamline data movement and checking.

# 4.1. Structure Definitions

Binary block data read and write commands transfer data in binary format. The user must prepare a message buffer with the required header space for the data to be read or written. The following structure definition, found in `dr_api.h`, contains the message header.

        typedef struct
        {
                char              cmd;
                char              dev;
                char              buffer;
                unsigned short    buf_size;
                unsigned short    size;
                unsigned short    offset;
                short             status;
                char              data[1];
        } DR_ApBlkHdr_t;

        sizeof (DR_ApBlkHdr_t) + DATA_LENGTH -1.

The `cmd` element must be set to one of the following:

`DR_API_BLK_WR`
`DR_API_BLK_RD`
`DR_API_BLK_CONTROL_WR`
`DR_API_BLK_CONTROL_RD`
`DR_API_BLK_STATUS_RD`

The contents of the structure elements `dev`, `buffer`, and `offset` (byte offset) depend on the specific device used. `size` specifies the number of bytes to be read or written, while `buf_size` indicates the total data buffer size available for returning data. Even during writes, the data buffer size available should be large enough to contain potential error strings (typically at least 64 bytes). `buf_size` must be greater than or equal to `size`.

When the data block is returned, `size` is set on a read to the number of bytes transferred. If `status` is non-zero, then an error occurred, and an error string may appear the data field (in place of data on a read).

Prev | Home | Next
API Specifications | Up | Message Format

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.