Jump to content
noplo

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,

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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,

Share this post


Link to post
Share on other sites

When using CLNs and *especially* when directly manipulating memory, save your VI before every time you run it! I can't count the time of times I've crashed LabVIEW mucking around with CLNs.

Share this post


Link to post
Share on other sites

Hello guys, I wasnt' able to manage the DLL as suggested so I did a wrapper DLL in CVI in order to be called from LabVIEW and now it looks ok.

Thanks,

Andrea

Share this post


Link to post
Share on other sites

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.


  • Similar Content

    • By Andersen Chen
      hello everybody,
      i want to index column 0~39,how to achieve and simplify
      thank you for help
      array.vi
    • By bingbot
      1: How to get last index, not last element, but last index number of an 2d array?
       
      Also
       
      2: say 2d array has contents
       
      elephant  crow    dog      goat
      giraffe      eagle   cat       fly
      ant          pig        horse   bee
       
      How to get that the bee is the 12th or 11th index in the array? (11 if you count elephant as zero index, 12 if you count elephant as first index), meaning I want the index number 11 or 12, not "bee"
    • By pkeny
      Hello,
       
      I am having trouble on learning what to do after you input a file into labVIEW. I cannot seem to find help on this topics. I have seen many videos and tutorials on how to read and write excel/text (.csv) files. But, I am not able to do anything after importing an text/excel file into labVIEW.
       
      So, I was wondering if someone had a simple VI that they could share. In the end, I want to do some automation so it will read a number and a status from excel. And then that number and status will either turn on or off a switch which controls something else. 
       
      Anyways, I would greatly appreciate if someone could share a VI as an example of how to manipulate the data to control something after you import a text/excel file into labVIEW.
    • By chris754
      (If this is not the right forum, please move as appropriate)
       
      Yesterday, I was trying to capture the "key down?" event on a string array control. I noticed that the event would never get fired while typing into one of the strings in the array. The event does fire if you type in the index control of the array. My question: Is this expected behavior or a bug? After trying a few things, I can get the behavior I want by getting a reference to the "ArrElem" and registering it for the "key down?" event and passing the into the dynamic event terminal. This is fine for my purposes and will implement my code in this fashion. However, I certainly was not expecting this event to behave in this way. I guess I could see why this may be the case (you are typing into a string control, not an array) but curious what other people think...
       
      This was all done in LV2013.
       
      Thanks!
    • By Dustin
      I've run into an interesting problem using the Open G variant library.  When trying to extract a list of cluster element names from a cluster in an empty array of clusters in a cluster itself, I get the following error from the Open G "Get Cluster Element Names VI":
       
       
       
      An example VI showing the problem is attached.
       
      At first I thought the problem was due to the fact the array is empty, but asking for cluster names of an empty array of clusters that is not in a larger cluster completes without error.
       
      Any thoughts on the cause or solution to this problem?
       
      empty array of clusters problem.vi

×
×
  • Create New...

Important Information

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