04-19-2011 09:44 AM
Hello,
I have written a .dll using CVI and am trying to use functions available in it using TestStand. I am getting strange errors, not always though when I run TestStand. Here is my code in dll.
int GetAverage (double* aBuffer, unsigned int aSize, double* aAverage) { double total = 0; enum t_eErrorCode eErrorCode = 0; if(aSize <= 0) { eErrorCode = eARRAY_SIZE_ZERO; goto Error; } for(int i = 0; i < aSize; i++) total += aBuffer[i]; *aAverage = total / (aSize); Error: return eErrorCode; }
It only sometimes throws an error eError_SIZE_ZERO, although when I checked in TestStand debugger, the size sent to the function was not zero (please see attachment).
What can be the reason or what am I doing wrong?
Thanks in advance,
RB
Solved! Go to Solution.
04-20-2011 01:29 AM
Hi RB
This sounds really strange.
Maybe there is a TpyeCast problem.
TS stores all its numbers a double. So you TS will cast!
If possible I would set a breakpoint on Error in CVI or i would place a second
errorcode to check if it is < 0
Hope this helps
Juergen
04-20-2011 01:39 AM
Hello Juergen,
I can try that.
I think you mean that I am passing 64 bits to CVI and since aSize is declared there as "unsigned int" it is considering only LSB which are all zeros. But if this is tha case then it should always be zero I think.
Do you know if I can step into a dll and debug it? Somehow it should be possible because I remember that once I had an exception in dll and TestStand asked me "If I wanted to debug it" and stepped into the dll code.
Thanks and regards
RB
04-20-2011 02:51 AM