LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DLL custom data type

Solved!
Go to solution
I'm not claiming that it couldn't be done wothout wrapper Dll. However it is my true and deepest belief that the LabVIEW diagram only solution is more cumbersome, error prone and true maintenance nightmare than writing a wrapper Dll. I can understand that someone who doesn't know how to write a wrapper dll in C might be tempted to cling to the option of doing ot all in LabVIEW only but this is really a catch 22.If one doesn't understand C enough to be able to write such a wrapper dll, one has 0 chance to get the LabVIEW diagram fiddling correct since you have to know even more about how a C compiler lays out data in memory than if you write a wrapper. In C a lot of the hassles are automatically taken care of by the compiler. And with a little care adapting the wrapper to 64 bit Windows is a simple recompile, while for a LabVIEW only solution you can't avoid reviewing the entire code and create alternate conditional code sequences for each bitness.
Rolf Kalbermatter
My Blog
0 Kudos
Message 11 of 25
(1,210 Views)

Hi guys,

Thanks for the replies and discussion so far. It seems to me that the Wrapper DLL is a safer option, but I still wanted to know how it's done in LV - this is not for production code, but for quick prototyping and testing of some data processing algorithms. Hence, @nathand, would it be ok if I sent you the files to your Email rather here?

Cheers,

E

0 Kudos
Message 12 of 25
(1,194 Views)
Are you unable to attach the files to a message here? I'd much prefer that so that other users with the same question can see the a solution.
0 Kudos
Message 13 of 25
(1,186 Views)

Hi nathand,

Sure. Attached.. The prototype of the DLL function is in the dll.h file (calculateRowingPattern). The data type is emxArray_real_T and defined in the "rowingPattern_types.h" file. Let me know if you need anything else. Thanks for looking at this.

Cheers,

E

0 Kudos
Message 14 of 25
(1,174 Views)

Again, I need documentation explaining how the struct elements are used. Is size an array, or more likely a scalar? What is allocatedSize? It's not simply a matter of matching data types. Without more information, I can't help.

0 Kudos
Message 15 of 25
(1,159 Views)
Just a guess but size is likely an array with 1 or 2 elements depending on the number of dimensions. allocatedSize is the number of elements (or bytes, which is quite a difference) allocated with malloc() or maybe another memory allocator (Windows API CreateHeap() maybe??? ). And it is e buffers or if the DLL will do it, and depending on the used allocator one has to use the matching deallocator in the end to avoid memory leaks.

In short, this API is very complicated and without a lot more documentation in prosa form not callable even from C.
Rolf Kalbermatter
My Blog
0 Kudos
Message 16 of 25
(1,154 Views)

HI guys,

Can this help out?

http://www.mathworks.com.au/help/fixedpoint/ug/c-code-interface-for-unbounded-arrays-and-structure-f...

Table "C Code Interface for Structure Fields" outlines a description of the structure.

Cheers,

E

0 Kudos
Message 17 of 25
(1,136 Views)

That's a start but not enough. What does the global_locs parameter need to contain before calling the function? Does it need to be initialized to an array of a particular size, or does the CalculateRowingPatterns function initialize it? Does it need to contain any values or is it an empty array? It seems like the easiest thing to do is to use the appropriate emxCreate function described in your link. What are the dimensions of the global_locs array? What data do you need to get out of it?

0 Kudos
Message 18 of 25
(1,121 Views)

Yep. Global_locs is an empty array and it returns the locations of peaks found in the data - the number of peaks will obviously change according to the data set.

Cheers

 

0 Kudos
Message 19 of 25
(1,116 Views)

Still not enough information. Is it a 1D array, 2D, or more dimensions? Does the function allocate memory for the data, or does that need to be done in advance, and if so how many array elements need to be allocated?

 

EDIT: do you perhaps have an example showing how to call this function from C?

0 Kudos
Message 20 of 25
(1,113 Views)