LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

structure pointer dll

Solved!
Go to solution

Need some help here, as I have tried everything I can think of.

 

Created a cluster, representing the structure and in die call function I have set 'Adapt to Type' and array data pointer, but this keeps failing as you can see below

 

Will appreciate any help/advise to get this working...

 

 

0 Kudos
Message 1 of 12
(5,549 Views)

Image below and attached

help2.jpg

0 Kudos
Message 2 of 12
(5,528 Views)

You add strings to the cluster. They will be passed to the DLL as LabVIEW string handles, something only DLLs can handle that have been specifically written to work with LabVIEW datatypes.

 

The real solution depends on how your structure is defined in C. If it contains fixed size string arrays, you have to replace that with a LabVIEW cluster with as many U8 or U16 integers as your fixed size string is defined. If they are defined as string pointers you have to place an uInt32 (for 32 bit LabVIEW) or an uInt64 (for 64 bit LabVIEW) for each string pointer and do some pretty convoluted memory management on your own (which you also would have to do if you used that function from a C program).

 

Your structure is however defined to contain fixed size arrays so the first solution is applicable.

 

You also need to check your structure again. aIPAddr is a cluster of 16*U8 elements and abMACAddr is a cluster of 6*U8 elements, not a single U8 element. Time is an int which is a signed integer that translates in LabVIEW to an int32. IsDHCPAssignedIP up to NumIPConnectionsIsValid are single char elements not a string and therefore translate to a single uInt8 in LabVIEW. And finally aPadding is again a cluster of 34*U8 not a single U8.

Rolf Kalbermatter
My Blog
0 Kudos
Message 3 of 12
(5,514 Views)

Thank you for your reply and information.

I updated the structure, but still get the error message.

Would you mind having a look at the VI and let me know what I am doing wrong?

Much appreciated.

0 Kudos
Message 4 of 12
(5,462 Views)

I said you should replace the fixed size array elements in the structure with a LabVIEW Cluster with as many elements as the fixed size specifies. You replaced the strings with arrays which for the purposes of C are still LabVIEW handles (pointers to pointers) and that is COMPLETELY different to a fixed array in C (and even to a variable sized C array pointer).

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 12
(5,447 Views)

I tried the cluster approach but still got the error, then tried the array, which is the vi I attached) which also fail.

Would you mind updating this vi to what you believe will work ?

Cheers 

0 Kudos
Message 6 of 12
(5,436 Views)
Solution
Accepted by topic author morngoose

This should work if you set the DLL and function name and make sure the calling convention is right.

 

structure.png

Rolf Kalbermatter
My Blog
Message 7 of 12
(5,429 Views)

Thank you, I've certainly learned something new.

0 Kudos
Message 8 of 12
(5,384 Views)

I have question for Use unsigned char array input Dll. But  The Labview Array to cluster only can set size=256 byte.

But Our program must input 4028 byte. How can I do?

 

Thank you

Autocar

0 Kudos
Message 9 of 12
(4,641 Views)

While your question is related to the original thread, this topic is 3 years old and already marked solved, you might want to start a new thread.

 

In your case, the easiest solution would be to initialize an array containing the number of bytes in the entire structure (so 6*4 + 4128 = 4152) and pass that in place of the structure. Combine the first 4 bytes to get the ProtocolID field, the second 4 bytes for RxStatus, etc with the last 4128 bytes being the data. You might have to reorder the initial bytes to get the endianness right.

0 Kudos
Message 10 of 12
(4,637 Views)