03-17-2011 07:05 PM - edited 03-17-2011 07:06 PM
Hello,
I have a function:
Member | Effective values |
---|---|
year | |
month | Between 1 and 12. |
day | Between 1 and 28, 29, 30, or 31. (Depends on the month.) |
hour | 0 to 23 |
minutes | 0 to 59 |
seconds | 0 to 59 |
ind | Relationship of local time to Universal Time (" ", +, −, or Z). |
off_hour | If "ind" is not space, 0 to 23 is valid. Otherwise, ignored. |
off_minutes | If "ind" is not space, 0 to 59 is valid. Otherwise, ignored. |
Solved! Go to Solution.
03-17-2011 08:33 PM
ps. HPDF_INT is just signed int so a 32bit signed integer.
03-18-2011 07:13 AM
No one?
Well I uploaded a example. Before running you need to set the path right from where it fetches the .dll in the Call Library VI
Hope someone can help.
03-18-2011 09:44 AM
Do you have the source headers of the DLLs you are using and have you tried using the Import Shared Library function?
Also, right click on your Library Node and generate the corresponding c file. Check to see if there are any differences between the c file generated and your headers. In this way, you can go about fixing your clusters to make sure they map to the structs properly.
03-18-2011 11:50 AM
Yes I have the source of the dll and I didn't try that function, Import Shared Library, I didn't knew it excisted. I just tried and I need to give a header file... But my dll exists out of multiply of h. files and c. files. How do I know which one to choose?
I will gonne try the second part of your answer now.
I'll keep you updated.
03-18-2011 01:27 PM - edited 03-18-2011 01:34 PM
EDITED: I'm not sure you can pass a struct by value in LabVIEW.
Part of the problem is that you've replaced what should be a "char" in the structure with a string. Try making "ind" a U8 integer instead. In LabVIEW, you can convert that to a string by running it through build array, then using Byte Array to String. To go the other direction, do the reverse - use String to Byte Array, then index element 0. You might be able to use typecast instead.
03-18-2011 01:43 PM
Sorry for my slightly confused earlier message; I replied too quickly. LabVIEW cannot pass a struct to a DLL function by value. You'll need to write a wrapper function in C that takes a pointer to the appropriate structure, dereferences the pointer, and passes that to the library.
My initial comment about the difference between a char and a string still applies. If you do write a wrapper as suggested above, you'll want the "ind" parameter to be a U8 as I suggested, not a string. Also, depending on your compiler setting and how the library was compiled, you may need to add padding bytes after the "ind" parameter to align "off hours" and "off minutes" properly.
03-18-2011 06:16 PM - edited 03-18-2011 06:17 PM
Actually LabVIEW can. A struct passed by value is simply pushed element for element onto the stack. So instead of defining a structure to pass as a single parameter to the CLN, you configure the CLN to take one parameter per structure element (and use the right datatype of course).
03-18-2011 07:18 PM - edited 03-18-2011 07:25 PM
Question Rofl. What do you mean with CLN?
And I tried the workaround with a U8 but wasn't succesfull. Furthermore there is really no solution to get this working? I mean this isn't even a very complicated struct.. 😕
03-19-2011 02:34 AM
CLN = Call Library Node.
U8 is correct so stay with that. But you will have to configure one CLN Parameter per Cluster element.