bufferInit

bufferInit — allocates a size to a specified buffer.

Synopsis

(bufferInit card_id buf_id size)
	

Parameters

card_id
The target card ID (0..3).
buf_id
The ID of the buffer to be initialized. Available buffers are listed below.
size
The number of bytes to allocate. The total combined size of all allocated buffers cannot exceed 12 Kbytes.

Returns

If the buffer is initialized successfully:

(bufferInit card_id buf_id size)

Otherwise, one of the following error messages:

(error "bufferInit DR_ERR_CARD_INVALID (time) invalid card: card_id")
(error "bufferInit DR_ERR_BLK_INVALID (time) invalid buffer id: buf_id")
(error "bufferInit DVN_ERR_BUFFER_ALLOC (time) failed to allocate buffer: buf_id")
[Note]

The DR_ERR_BLK_INVALID error can also indicate that the buffer has already been initialized.

Description

This command allocates the specified buffer with a particular size. The buffers defined by this command mirror in the driver the various areas of memory contained in the card. Allocation of the buffers and managing of the card memory is done automatically by the driver as needed (for example as part of the dnsOnline and dnsDeviceAdd commands), using specified size parameters, or default sizes.

This command gives the user greater control of the buffer sizes, allowing the card memory usage to be tailored to the requirements of a particular installation. The following table provides a list of the buffers defined in the DVN Driver (see dvn_api.h in the distribution), along with the default size value.

Table 1. DVN Driver Buffers

Buffer IDBuffer NameDefined size (bytes)
0DVN_BUF_OUTPUT4K
1DVN_BUF_INPUT4K
2DVN_BUF_SERVER_OUT(see dnsOnLine)
3DVN_BUF_SERVER_IN(see dnsOnLine)
4DVN_BUF_SERVER_REQUEST64
5DVN_BUF_SERVER_RESPONSE64
6+(0..63)DVN_BUF_DEV_MSG+(0..63)64, (see dnsDeviceAdd)

The bufferInit command must be used after cardInit (requires that a card be initialized), but before buffers are automatically allocated by the dnsOnline or dnsDeviceAdd commands.

Example

> (bufferInit 0 1 6144)
(bufferInit 0 1 6144)
> (bufferDescribe 0)
(bufferDescribe 0 (1 6144 0x1000 0))
> (dnsOnline 0 0 0 1024 0)
(dnsOnline 0)
> (bufferDescribe 0)
(bufferDescribe 0 (1 6144 0x1000 0) (2 1024 0x2800 1024)
    (3 256 0x2C00 256))
> (dnsDeviceAdd 0 2 7 6)
(dnsDeviceAdd 0 2)
> (bufferDescribe 0)
(bufferDescribe 0 (0 4096 0x2D00 6) (1 6144 0x1000 7)
    (2 1024 0x2800 1024) (3 256 0x2C00 256) (8 64 0x3D00 0))