06-09-2009 11:15 AM
Hello,
I'm using a 6602 DAQ device. I want to make an edge counter in C\C++ (compilate with gcc on windows) but I've got strange behavior :
Here is a part of test source code:
// DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI38",3e7,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000);
i=0;
// DAQmxErrChk (DAQmxReadCounterU32(taskHandle,-1,-1,data,1000,&num,NULL));
while(i<=3){
cout << "i value is " << i << endl;i++;
}
gives
Data acquisition ready to start
i value is 0
i value is 1
i value is 2
i value is 3
End of program, press enter to quit
If I uncomment line // DAQmxErrChk (DAQmxReadCounterU32(taskHandle,-1,-1,data,1000,&num,NULL)); or
// DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI38",3e7,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000); or both I get errors.
With only one uncommented :
Data acquisition ready to start
i value is 0
End of program, press enter to quit
and with both uncommented :
Data acquisition ready to start
i value is 2147332096
End of program, press enter to quit
I don't know what to do.
Maybe use python to use C functions ?
Regards,
Thibaut
PS : I'm net sure to be in the right section.
06-15-2009 04:27 AM
Hi Thibaut,
Which version of DAQmx do you use?
Is it specific to DAQmx counter task?
Regards
Yann C.
France
06-17-2009 04:53 AM
Hi Yann,
I'm Thibaut and post from another account.
DAQmx version is 8.7.1
I haven't test other features than counter.
The matter is a buffer overflow. Could he came from :
DAQmxErrChk00 (DAQmxReadCounterU32(taskHandle00,-1,-1,data00,N,&num00,NULL));
while(i<=num00)
{
cout << data00[i] <<endl;
i++;
}
Regards,
Thibaut
06-19-2009 09:01 AM
Hi Thibaut,
See this KB to avoid overflow in acquisition.
How do you know it's a buffer overflow.
Regards
Yann C.
France
06-19-2009 10:23 AM - edited 06-19-2009 10:27 AM
Hi,
I explain in the first post that a for loop is affected by some DAQmx functions whereas the loop is totaly independant from those functions.
So we tried to put the variable that control the loop in the middle of a large array (it's not a joke :))
It works for some things but we can't use multiple threads or write data on the disk.
Thibaut
06-22-2009 04:45 AM
Hi,
Gcc is not supported, how did you do to use the the DAQmx library with gcc?
Regards
Yann C.
France
07-10-2009 02:55 PM - edited 07-10-2009 02:56 PM
Hi Thibaut,
If the variables "data" and "i" are allocated on the stack, then I agree that this sounds like a buffer overflow. Could you please post more of your code, such as the DAQmx task/channel creation code and the declarations of all of the stack variables?
Also, since you're using an unsupported compiler, you should check that you are using the correct calling conventions.
Brad