Hello,
I've hit a snag while using NI-DAQmx Base (I'm on Mac OS 10.4, compiling with gcc 4.0). The documentation says that calling DAQmxBaseReadAnalogF64 with numSampsPerChan (the second argument) set to -1 (DAQmx_Val_Auto) will cause whatever is in the buffer to be read. However, when I do this, only 2 samples are read (even though many more are clearly in there). This seems to happen irrespective of what sampling rate I've set the channel to.
I set the sampling clock like so:
status = DAQmxBaseCfgSampClkTiming(analog_input_task_handle, "OnboardClock",
(float64)analog_input_rate, DAQmx_Val_Rising,
DAQmx_Val_ContSamps, 0);
so there should be continuous sampling (analog_input_rate is typically a few kS/s). Changing the value of the final parameter makes no difference.
I'm reading the channel like so:
#define NIDAQ_BUFFER_SIZE 1000
float64 read_array[NIDAQ_BUFFER_SIZE];
status = DAQmxBaseReadAnalogF64(analog_input_task_handle, -1, (float64)NIDAQ_TIMEOUT,
DAQmx_Val_GroupByChannel, read_array,
(int32)NIDAQ_BUFFER_SIZE, &samples_per_channel, NULL);
samples_per_channel ends up always being two, and if the sampling rate is at all high, then the onboard buffer eventually overruns. If I set the second argument to something like 1000, it merrily reads the data out, but if I check too frequently, it blocks until it's gotten 1000 samples, and I check too infrequently, it gradually falls behind and blows up. Neither scenario is unacceptable behavior in my application.
I'm pulling my hair out. What gives?
Thanks,
Dave