Kyle,
I have not been able to reproduce this behavior. I used the following code (very similar to yours). When setting the read relative property and letting the buffer overflow, I do not get an error, nor do I get a nonzero return value from the analog read. When I eliminate the three lines following the comment, I do get error -200279 (Attempted to read samples that are no longer available).
How are you getting this error? Do you have error handling implemented elsewhere in the code? Please let us know!
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
char errBuff[2048]={'\0'};
int32 read=0;
float64 data[1000];
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev2/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",10000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));
//Comment out these lines to get an error
DAQmxErrChk (DAQmxSetReadOverWrite(taskHandle, DAQmx_Val_OverwriteUnreadSamps));
DAQmxErrChk (DAQmxSetReadRelativeTo(taskHandle, DAQmx_Val_MostRecentSamp));
DAQmxErrChk (DAQmxSetReadOffset(taskHandle, 0));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf("Acquiring samples continuously. Press Enter to read\n");
getchar();
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000, -1, DAQmx_Val_GroupByScanNumber, data, 1000, &read, 0));
Error:
printf("Error Number: %d\n\n",error);
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
Regards,
Ryan Verret
Product Marketing Engineer
Signal Generators
National Instruments