www.vtiinstruments.com
EX1629 Programming 89
5 7
0 2
3
HD
LAN
SHUNT
CAL
RES
SHUNT
CAL
RES
SHUNT
CAL
RES
1
4 6
13 15
8 10
11 9
12 14
21 23
16 18
19 17
20 22
29 31
24 26
27 25
28 30
37 39
32 34
35 33
36 38
45 47
40 42
43 41
44 46
PWR
EX1629
time time
Receive streaming data
Receive streaming data
Receive streaming data
Receive streaming data
Receive
:
vtex
1629
_
trig
_
init
()
response
Send
:
vtex
1629
_
enable
_
streaming
_
data
()
request
Receive
:
vtex
1629
_
enable
_
streaming
_
data
()
response
Send
:
vtex
1629
_
trig
_
init
()
request
User callback
User callback
User callback
User callback
User callback
FIGURE 6-3: STREAMING DATA WITH USER CALLBACK
The following sample code segment illustrates a very basic use of the streaming data interface.
The callback function, stream_callback, just prints the timestamps and data values to a FILE
handle. The FILE handle, as well as a sample count total variable, are stored in a user-defined data
structure. A pointer to this structure is passed to the vtex1629_enable_streaming_data function,
along with a function pointer to the streaming callback function. Later, when streaming data pages
(scans) are received, a pointer to the acquisition data, along with the pointer to the user-defined
data structure, are passed to the callback function. The user-defined data structure pointer is passed
as a void* and should be cast to the appropriate type within the callback function.
#define INSTR_LANGUAGE_SPECIFIC
#include<vtex1629.h>
typedef struct {
FILE *fout;
ViInt32 sample_count;
} user_struct;
user_struct my_struct = {0};
ViInt32 stream_callback( void *priv, EX1629_rpc_datapage *data )
{
user_struct *priv_struct; // pointer to user structure
ViInt32 ds_idx; // dataset index
ViInt32 smp_idx; // sample index
priv_struct = (user_struct *)priv;
/* Loop through all of the datasets in the datapage. */
for( ds_idx = 0; ds_idx < data->dataset.dataset_len && ds_idx <
MAX_NUM_DATASETS; ds_idx++ ) {