11-19-2014 12:54 AM
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...
Solved! Go to Solution.
11-19-2014 02:03 AM
Image below and attached
11-19-2014 05:37 AM - edited 11-19-2014 05:46 AM
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.
11-21-2014 12:37 AM - edited 11-21-2014 12:38 AM
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.
11-21-2014 03:27 AM
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).
11-21-2014 04:33 AM
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
11-21-2014 05:28 AM - edited 11-21-2014 05:31 AM
This should work if you set the DLL and function name and make sure the calling convention is right.
11-24-2014 01:34 AM
Thank you, I've certainly learned something new.
11-02-2017 09:49 AM
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
11-02-2017 12:34 PM
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.