Synchronous read issues with nidaqmx-python
It initially appears that reading from digital IO with nidaqmx-python
may be synchronous, causing too long to loop over reads, yielding error messages as below.
I wonder if nidaqmx.streaming_readers
is required to read asynchronously as the name implies?
nidaqmx.errors.DaqError: The application is not able to keep up with the hardware acquisition.
Increasing the buffer size, reading the data more frequently, or specifying a fixed number of samples to read instead of reading all available samples might correct the problem. Property: DAQmx_Read_RelativeTo Requested Value: DAQmx_Val_CurrReadPos
Property: DAQmx_Read_Offset Requested Value: 0
Task Name: _unnamedTask<0>
Status Code: -200279
Problematic nidaqmx
synchronous read code
This code reads 3 binary lines at once via the Port interface
from time import time
import nidaqmx as nd
with nd.Task() as task:
task.di_channels.add_di_chan('Dev1/port0/line0:2',
line_grouping=nd.constants.LineGrouping.CHAN_PER_LINE)
task.timing.cfg_samp_clk_timing(rate=Fs,
sample_mode=nd.constants.AcquisitionType.CONTINUOUS,
)
print('initializing',fn)
with h5py.File(fn, 'w') as f:
f['tstart'] = time() # TODO use GPS time over serial instead
b = f.create_dataset("di",(3,Nframenight),dtype=bool)
sleep(3)
print('starting fire log loop to',fn)
i=0
while True:
tic=time()
data = task.read(number_of_samples_per_channel=Nsampread)
print(time()-tic)