04-02-2007 09:48 PM
04-04-2007
01:16 PM
- last edited on
03-31-2026
01:01 PM
by
Content Cleaner
Hello David_Lin,
There are several things you want to consider when getting a buffer overwritten error. What error code number did you get?
Take a look at these resources: [broken links removed; articles no longer available]
How Can I Avoid Error -10846 (Overwrite Error) in LabVIEW?
Data Acquisition Errors -10845 and -10846, What Is the Difference?
With regards to your code. As I see it when you set the read relative to, you are specifying the point in the buffer at which to begin a read operation. You have selected the DAQmx_Val_MostRecentSam, it starts reading samples relative to the next sample acquired. What have you set as the offset? If you set the offset to -1, this will read the last sample acquired.
I see that you are also using the "DAQmxGetReadAvailSampPerChan" function, which gets the status of the available samples per channel property. This property indicates the number of samples available to read per channel.
Take a look at the NI DAQmx C Reference Help, it is an awesome resource to refer to when coding with the DAQmx driver.
I'm not quite sure I understand what the issue is. Can you please clarify? Are you then doing a DAQmx read and getting "0" instead of real data?
Regards,
Sandra T.
Applications Engineer | National Instruments
04-04-2007 09:29 PM
"I see that you are also using the "DAQmxGetReadAvailSampPerChan" function, which gets the status of the available samples per channel property. This property indicates the number of samples available to read per channel."
Yeah, it is exactly where my problem is. I tried to get the available samples per channel, but it always returns zero, which means no sample is available all the time. There must be something thing wrong. Then I change the tast from continuous sampling to finite number sampling and then it worked correctly. Why didn't DAQmxGetReadAvailSampPerChan work in continous sampling mode? Is it because I set DAQmx_Val_MostRecentSam? For the offset, I didn't change it and it should be the default value.
David
04-05-2007 09:43 AM
04-08-2007 08:32 PM
Actually, I did start the task after I configured DAQmxSetReadRelativeTo. I just forgot to paste the code.
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",SampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,BuffSize));
DAQmxErrChk (DAQmxSetReadRelativeTo(taskHandle,DAQmx_Val_MostRecentSamp));
DAQmxErrChk(DAQmxStartTask(taskHandle));
Then I use DAQmxGetReadAvailSampPerChan to check the available number of samples as
DAQmxErrChk(DAQmxGetReadAvailSampPerChan(taskHandle,read));
The problem is read always returns zero.
David
04-09-2007 11:11 AM
02-22-2018 09:46 AM
Hi,
Turns out I am having exactly the same problem. Continuous acquisition is working fine for reading a defined number of samples (read function returns immediately) but I cannot manage to have the read all available samples working (see https://github.com/ni/nidaqmx-python/issues/49).
The function DAQmxGetReadAvailSampPerChan is always returning zero for me too.
Is there any solution for this problem?