www.vtiinstruments.com
EX1629 Programming
89
`
Host Computer
EX1629
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
Rece
ive s
tream
ing d
ata
Rece
ive s
tream
ing d
ata
Rece
ive s
tream
ing d
ata
Rece
ive s
tream
ing d
ata
Rece
ive:
vtex
1629
_tri
g_in
it()
resp
onse
Send:
vtex16
29_ena
ble_st
reamin
g_data
()
reques
t
Rece
ive:
vtex
1629
_ena
ble_
stre
amin
g_da
ta()
resp
onse
Send:
vtex16
29_tri
g_init
()
reques
t
User callback
User callback
User callback
User callback
User callback
F
IGURE
6-3:
S
TREAMING
D
ATA
W
ITH
U
SER
C
ALLBACK
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; + ) {