04-23-2013 04:04 PM
I am trying to feed a 2D array (image reading) to a DLL, but it always gives a 1097 error. I debugged the original C++ code. It narrows down to the point that some pixels cannot be read. So I write a simple C code to reproduce the issue.
As you can see from the following screenshot, this C code simply returns the number indexed by 'index'. When fed from Labview to the DLL, I chose to feed a 2D array as 'Array Data Pointer'. Then I put it in a for loop to read through the entire array. The returned array showed that the cells after 75th row cannot be read with a 1097 error. But why? What did I do wrong?
04-23-2013 07:48 PM
Hi,
Is it possible that when you index past the 75th row, it's past the end of the supplied data? Your DLL expects the input to be an array of Doubles (8 bytes), but you're passing in a table of ? I32? If I32 then you're pre-allocated array is half as big as needed. Try chainging the type of the initialize-array to U64 and see what happens...
Cheers!
04-24-2013 08:34 AM
That was my first guess too. But it is not the reason. You can tell that there is not type conversion into the DLL. I specifically made them both the same type, the U32.
04-24-2013 10:42 AM
Yes, initialize-array initializes a table of I32, and the type in the CLF matches, but the DLL is still indexing into (what it thinks is) an array of Double - see the function syntax the C source-code: "(double *x",...).
If you simply change the initialize-array type to U64, it will allocate enough space. It's not even necessary to correct for type conversion - you're still passing a pointer, the DLL will be happy.
04-24-2013 11:16 AM
Probably better to change the DLL from "double" to "int" to match the data that you're actually passing to it. A double is 64 bits. An int is 32 bits. The array indexing operator in C knows the size of the array data type and uses that to compute the offset from the start of the array. When you pass data that's of a different type, the array indexing doesn't work properly. As 550nm explained, the data types need to match between the C function and the LabVIEW data.