Jump to content

Managing Structures with Array of Structures as DLL input parameter


Recommended Posts

Hello all,

I have the following problem. I'm using an external DLL in LabVIEW and one of the functions require a structure as an input parameter.

Here's the structure:

struct Pippo {

DWORD ipAddress;

DWORD centerFrequency;

Pluto* array

};

struct Pluto {

DWORD size

DWORD address

}

The function prototype is the following:

myfunction( Pippo input )

I've used the Import Library Wizard from LabVIEW and it extract every field from the structures. So what I get as the function inputs is:

ipAddress,centerFrequency,size,address.

So basically the array is not treated and I get the 1097 error:

LabVIEW: An exception occurred within the external code called by a Call Library Function Node. The exception might have corrupted the LabVIEW memory. Save any work to a new location and restart LabVIEW.

I've read other threads from this forum and I tried to create the Pluto array of clusters but still the same error.

How can I run the function correctly with these parameters?

Thanks,

Link to comment

How do you know how many elements are in the array of Pluto structs?

The two attached CLNs will help you operate with points. The second is useful for arrays of known length. Both are examples of operating on 4-byte signed integers.

post-13461-0-81664600-1346251206.png

post-13461-0-11670700-1346251216.png

These look like snippets, but they are not. They were sourced from this article: Dereferencing Pointers from C/C++ DLLs in LabVIEW.

Link to comment

How do you know how many elements are in the array of Pluto structs?

The two attached CLNs will help you operate with points. The second is useful for arrays of known length. Both are examples of operating on 4-byte signed integers.

post-13461-0-81664600-1346251206.png

post-13461-0-11670700-1346251216.png

These look like snippets, but they are not. They were sourced from this article: Dereferencing Pointers from C/C++ DLLs in LabVIEW.

Extra complication: The function may expect the array to be allocated by the caller too. If that is the case can only tell the documentation to that function. C is simply not detailed enough to describe the finer semantics of parameter passing.

  • Like 1
Link to comment

Thanks guys for the answers.

I'm sorry I forgot an information. In the Pippo structure there's an extra field that tells me the dimension of Pluto.

struct Pippo {

DWORD ipAddress;

DWORD centerFrequency;

BYTE PlutoArraySize

Pluto* array

}

So I know how many elements are in the Pluto array.

I'm going to try what you suggested and let you know.

Thanks,

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.