From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a C Struct from a LV CallLibrary Function.

It's not clear what you are trying to do here. You show a function with only one parameter in its argument list, but the LabVIEW screenshot shows two parameters. Why doesn't your cluster match the structure in the C code?

 

Please provide the actual C header (.h) file or files for the DLL, along with a list of the functions you want to call. Then it will be possible to explain how to create the structures and call the functions correctly from LabVIEW. Without that specific information, I cannot understand what you want to accomplish.

0 Kudos
Message 31 of 36
(556 Views)

Hi nathan.

 

Thanks for the fast answer. i wanted to write you a pm but i am new in this forum. maybe we can write about it personal :).

0 Kudos
Message 32 of 36
(542 Views)

I don't provide individual help through personal messages. Please keep your questions on the public forum. That way you can get better help more quickly because more forum users can contribute, and you help future users who might have a similar problem.

 

Do I correctly understand that you have a C function "hid_get_current_table" that does not yet work, but you want to call it from LabVIEW? Why do you need to write that function in a DLL? Your current C function won't return any useful data, because there is no way for any of the hid_* functions (which have no parameters nor return type) to copy data into the pubtable array.

 

Are you writing the C code, the LabVIEW code, or both? What have you tested so far, and how much of it works? What is the actual function call for the hid_* functions? Can you call them directly in LabVIEW, instead of writing the hid_get_current_table function?

 

In a private message you also asked about this image. If you look at that page, below the image it says "Posted in" with a link to the thread where I posted that image. The code for it is available in that thread.

0 Kudos
Message 33 of 36
(528 Views)

Again, I will not provide help through private messages. I don't know what portion of this work is supposed to be your assignment, so I have to assume that anything that you do not feel comfortable asking publicly is work that you should be doing on your own. Also, new forum members often send private messages to several experienced users. If you did this, then I could be wasting my time writing a reply to a question that someone else has already answered. So keep everything public if you want help.

 

In a private message, you wrote:

The only problem is that i have an array of structs (each struct has 7 integer and one wchar string) and return this via a Call function node to an array of clusters (with cluster from 7integer and one string). And my first try is to make this possible with only integers (so without the string) So basically i do in Labview an constant of unsigned integer 16 with the value "0" and bundle it to an cluster, then i make "build array" to allocate the memory for this array of cluster. Then i do the CFN which has the form (int32_t hid_get_current_table(void pointer) ) and i want to give it out into an array on the frontpanel who has this cluster with 7 Integer. So i dont know how to get the data from the C function to the Labview function.

Have you tried only this one approach? What else have you done? How did you configure the Call Library Function Node? Did you try something simpler? For example, create a function in the DLL that fills elements into a single struct/cluster, instead of an array. Don't even bother with the hid_* functions, just fill in some constants and see if you can get the right data back in LabVIEW. Can you make that work? If so, change the parameter to an array, and confirm that it still works. Then add the hid_* functions. Do you know that those functions work? As I mentioned in my previous message, they cannot do what you describe given the prototypes you provided.

0 Kudos
Message 34 of 36
(513 Views)

Why does almost everybody who inquires about Call Library Node questions think that it is enough to write a little prosa and if they feel very generous add a (usually quite poor) screen shot of the VI in question and hope that they can be helped in any way?

 

The minimum required is the actual VIs you worked on already, and the entire header files (what is WSTR_LEN for instance, that isn't clear from the post alone). It's not always enough but anything less than this is simply a waste of time.

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 35 of 36
(497 Views)