flex_read_buffer

NI-Motion Functions

flex_read_buffer

Device Compatibility

Device Compatibility
7330
N
7340
Y
7344
Y
7350
Y
7390
N
NI SoftMotion Controller for CANopen—Xenus
N
NI SoftMotion Controller for CANopen—Accelnet
N

Read Buffer

Usage

status = flex_read_buffer(u8 boardID, u8 buffer, u32 numberOfPoints, u8 returnVector);

Purpose

Reads data from a previously configured buffer.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
buffer u8 buffer to read
numberOfPoints u32 number of data points to read from the buffer
returnVector u8 destination for the return data

Parameter Discussion

buffer is the buffer to read from. Valid buffer numbers are 1 through 255 (0x01 through 0xFF). numberOfPoints is the number of 32-bit data points to read from the buffer.

returnVector indicates the destination for the return data generated by this function. Available return vectors include return data to the host (0xFF), to a variable (0x01 through 0x78), to an indirect variable (0x81 through 0xF8), and return no data (0). Refer to Input and Return Vectors for more detailed information.

When returning data to a returnVector, you must limit the numberOfPoints to a number that fits in a sequence of onboard variables starting with the variable specified by the returnVector.

Using This Function

An input buffer can be written to after it has been configured, usually by an onboard program. After data is available to read, you read the data from the buffer with this function.

When the buffer is configured for a single iteration, you can wait until the buffer is full by checking the status of the buffer with the Check Buffer function, and then read the entire contents of the buffer. You also can read the smaller chunks of data from the buffer while the operation is in progress. The number of points available to read can be determined with the backlog parameter returned by the Check Buffer function.

When using the buffer as a circular buffer (totalPoints > bufferSize), with oldDataStop turned on, you need to read data from the buffer faster than the buffer is being filled with new data. You can determine the number of points you can safely read from the buffer by calling the Check Buffer function. The backlog parameter indicates how many points you can safely read from the buffer.

If you try to read data that has not yet been written to the buffer by the controller, the data is not read, and the controller generates an NIMC_oldDataStopError. However, if you configured the buffer with oldDataStop set to false, you can read data freely from the buffer, and the controller does not enforce the oldDataStop condition.

Under no circumstances can data be read from an output buffer (for example, contouring) after the specified number of points (totalPoints) has already been read from the buffer. An NIMC_illegalBufferOperation error is generated in this case.