Memory buffer allocation, Overview, Polling or dma system buffer allocation – Measurement Computing ADLIB WIN User Manual

Page 25: The buffer structure

Advertising
background image

Chapter 6 Memory Buffer Allocation

6-1

6. MEMORY BUFFER ALLOCATION

6.1 OVERVIEW

ADLIB WIN removes the complexity of allocating suitable DMA and Interrupt buffers by automatically
allocating buffer(s) when a DAQ board’s subsystem is initialized. The application programmer can then
retrieve a pointer to buffer and/or set up an ADLIB buffer message handler that will be called when each
buffer has been completed. ADLIB allows N buffers of size M for each DAQ board's logical device; the
only limitation on quantity and size of the buffer(s) is the amount of available host system memory.

6.2 POLLING or DMA SYSTEM BUFFER ALLOCATION

All buffers are allocated on behalf of ADLIB for DMA Acquisition during your applications device
initialization according to the buffer size and number of buffers specified.

6.3 THE BUFFER STRUCTURE

ADLIB WIN buffer pointers are not just pointers to a DAQ board's subsystem data, but are pointers to a
structure that contains the buffer type, size, linear data address, physical data address, current sample
count, hardware trigger points, completion flags, status flags, and error flags.

Some of these fields remain constant for the duration of the acquisition. Others contain relevant
information about the current condition of the buffer, and error conditions that occur in the hardware
device's subsystem during the current acquisition.

The three structure variables that provide state/status/error information are defined as follows:

DWORD dwDoneFlag

The Done Flag specifies the current state of a buffer. This flag can be set to
any of the three following conditions as defined in the ADLIB include file.

BUFFER_IDLE = 0

The buffer is available for use, but acquisition has not started
on this buffer.

BUFFER_DONE = 1

The buffer has been filled with samples and is available for
use in the user application.

BUFFER_INUSE = 2

The buffer is currently being filled with samples.

DWORD dwStatusFlag

The Status Flag specifies the completion status of a buffer. This flag can be set
to any of the four following conditions as defined in the ADLIB include file.

BUFFER_EMPTY = 1

No samples are available in the buffer.

BUFFER_INCOMPLETE = 2

The output buffer has not read completely or and input has
not filled to capacity.

BUFFER_COMPLETE = 4

The output buffer has been read completely.

BUFFER_FULL = 8

The input buffer has filled to capacity.

Beginning with Revision 3.0 of ADLIB, the upper word of the dwStatusFlag contains the hardware status
register state at the time of an error condition as described in the lErrorFlags below.

Advertising