Functions > di_buffer_status

Syntax 

The di_buffer_status function returns the location of the next entry in the scan list about to be entered into the buffer.

Syntax 

unsigned di_buffer_status(chn);

unsigned chn;

/* indicates whether to get the location of the next input channel (0) or output channel (1) */

Parameters

chn  

0 = input

1 = output

Note: Output functions are not available on all instruments. Check your hardware manual for output specifications.

The least significant bit of chn is the only bit checked to determine input or output. No bit is checked where output functions are not available.

Return Value

The di_buffer_status function returns an unsigned integer.

Dependencies

di_open

di_buffer_alloc

di_list_length

di_start_scan

di_inlist or di_outlist

Remarks

The size of the input or output buffer should be evenly divisible by the length of the scan list in order to use the pointer as a buffer index (or starting position of the next scan). The output channel index returned by di_buffer_status (1) indicates the buffer position that will be used for the next output to the device. An internal FIFO temporarily holds the data that is waiting for output to the DAC. As a result, when scanning is started, the pointer will quickly jump by the number of words in the FIFO when the empty FIFO is filled. To determine when a particular word has reached the DAC, wait until the returned value (minus the FIFO size from the following table) exceeds the output buffer index of the value in question.

  Device Output only Words Output word during Input
  DI-220 8177 4098
  DI-400 15000 6144
  DI-500, DI-720, DI-730 PP devices 7500 3072

Sample Code

#include "200sdk.h"

int *input_buffer,errcode;

struct di_mode_struct mode = {0};

struct di_inlist_struct inlist[256] = {0};

char errstr[255];

main()

{

if(errcode = di_open()){

/* open the device for comm */

di_strerr(errcode,errstr);

printf("%s",errstr);

}

if((input_buffer = di_buffer_alloc(0,4096) = = NULL)

/* allocate 4096 words for input */

printf("Insufficient memory or input buffer already allocated...\n");

if(errcode = di_list_length(1,0))

/* Set the input list length */

printf("Input list length error...\n");

if(errcode = di_inlist(inlist))

/* Set up the input list */

printf("Input list error...\n");

if(errcode = di_scan_mode(mode))

/* Set mode */

printf("Mode error...\n");

if(errcode = di_start_scan())

/* Start scanning */

printf("Start scan error...\n");

while(!kbhit())

/* Main loop executes until key hit. Prints last values in buffer. */

printf("Current value in buffer = %04X\r",*(input_buffer + di_buffer_status(0)));

if(errcode = di_close()){

/* close the device */

di_strerr(errcode,errstr);

printf("%s",errstr);

}

}

 

Copyright © DATAQ Instruments, Inc.