Jump to content

Send pointer of struct to DLL


Recommended Posts

Hi all
 
I new with labview & i need to take care of LV project at work, the past programmer work was to communicate with our HW during .DLL file {with defined C# function & objects}.    
my goal is to make this code active (the code is realy good except .dll functions that need to get pointer to struct and not intfloat etc.)
 
I already read the topics:
 
It deals with related issue, but in this case i need to deliver pointer to struct that already contains data this data already usee by the program and the .dll need to adjust it.
the dll functions doesn't return the struct value.
UINT32 BufferReadMeasurements(Measurement* measurementsArray, UINT32 offsetInBuffer, UINT32 numberOfMeasurementsToRead, DWORD timeOutMilliseconds);
}

 

in the code he sends instance of the struct with initialization to const values.
but the function need to get pointer to real struct .
(while i try to run it the program the stuck)
 
1. someone have an idea how can i do this ?       :frusty:
2. while i try to change VI patterns and insert more patches (want to wire it in different way)
i found out that the vi i adjust is seen transparent in its appearance at block diagram, this cause errors in the code, so how can i change the vi pattern without create new errors ? 
 
thenks 
Link to comment

How is the Measurement data type defined?

 

If the Measurement struct is fairly simple, you can create a matching cluster in LabVIEW, fill in the values, and pass it to the DLL function. The corresponding output from the Call Library Node will have the modified values after the call to the DLL.

 

Can you share your LabVIEW code, showing what you tried?

Link to comment

Hi ned

 

sorry for the latency it was weekend :)

Attached Measurement data type definition (.pdf).

 

The DLL input need to be pointer to array of measurements at C implementation it mean that the program reads the array and adjust it by 

jumping i*sizeof(One Measurement), therefore it needed to pass the exact database to the DLL and not shadow copy of the values.

 

for example my VI 'Show probe dialog.VI' (this function is working well) 

the function signature has two pointers one to a data destination, second to database to manipulate.

Attached pobe dialoge definition & implementation(img)- 

static bool ShowProbeDialog(ISmart** smartArray, int arrayLength, ProbeDialogParams* pdp, ProbeDialogResult* pdr);

 

At Probe_Dialog.VI data pass to function and labView take care for the pointers issue but in the other case - the measurements is complex struct and i can't make the same thing- create the struct and send it to the function this  attached the measurements vi.

 

do you have idea for this???

 

 

Measurement.pdf

post-52394-0-23636100-1404642257_thumb.p

post-52394-0-56531600-1404644185_thumb.p

Link to comment

You can pass clusters to a DLL, with the parameter configured as Adapt to Type. The cluster will be passed by pointer, like a struct. I recommend that you try this for your Show Probe Dialog VI, since it will eliminate splitting and joining numbers. LabVIEW will handle all that for you automatically.

 

You can likewise pass an array of clusters to the DLL using Adapt to Type. Set "Data Format" to "Array Data Pointer." You'll need to create a cluster that matches the format of the Measurement struct. This is easy if you're only using one of the members of the union. If you are using more than one member of the union, then you can either pass the data in a more generic format (for example an array of the correct number of bytes) and parse the data out later, or you can create a struct that matches one member of the union, and then reinterpret that portion of the data when dealing with other Measurement types.

 

See snippet below.

post-3989-0-82666100-1404763892.png

  • Like 1
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.