Chapter 4. Direct Interface Specifications

Table of Contents

4.1. Structure Definitions
4.2. Message Format

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).