Jump to content

Call Library Node Crashes LV in Edit Mode

Recommended Posts

I have create a LV wrapper for a DLL that crashes LV when the CLN is simply wired in edit mode and saved.  I will admit that the DLL prototype requires a rather obese LV cluster which is so large it freezes LV when probed but still I do not see any other way to convey the data.  Here is the diagram...

LV will crash when I connect the cluster to the 2nd input of the CLN and then Save.

The CLN function prototype is...

int32_t LDR_GetCsmuDir(uint16_t *DirType, void *Response);

The Response parameter is set to 'Adapt to Type', Pointer to Handle. 

I also tried 'Handles by Value' as it still crashes.


Basically I have a cluster of 256 strings each of which is 256 characters, which appears to be too much for LV to handle.  Perhaps there is a way to Malloc the data but that is outside my area of knowledge presently.

Edited by viSci
Link to comment

The line at the bottom isn't a function prototype; I'm not quite sure what it's supposed to be doing. Can you include more of the header file?

Data Format should be set to Array Data Pointer. You should never pass a LabVIEW handle to a DLL unless that DLL is specifically written to handle LabVIEW data types.

There's no need to take an empty string, convert it to an array, then type cast that to a cluster; bundle in the cluster constant directly. You could also ignore the structure entirely, compute the size of the cluster ((256 + 4) * 256) = 66560 bytes, initialize an array of that size, and pass that instead. Make sure to pass it as an array data pointer. You can then parse out the returned array however you like (accessing specific subsets, or attempting to convert it to the big cluster).

Link to comment

The Typedef on the last line was just meant to indicate that the DLL function takes two parameters, the first is a pointer to a U16 and the second is a pointer to the data structure I am trying to build.  I tried as you suggested, to create a large U8 array and pass it in as a pointer to array and adapt to type.  It no longer crashes in edit mode and now waits until I run the vi :)

Link to comment

Ok I realized I did not follow your instructions correctly.  After I changed 'Adapt to Type' to 'Array' it ran without crashing.  I am getting back an unstructured string but it is a starting point.  Thank you Ned, that was a big help!

Link to comment
16 hours ago, viSci said:

Hi Rolf - That was a very good try but short 2 bytes.  After that adjustment it works great, thanks!



That won't work for sure!!

This strange offset of 2 you added inside the loop would indicate that the according C code was not compiled with standard padding. A completely valid possibility although pretty unusual for DLLs that were not specifically compiled for LabVIEW.

Instead you should most likely have changed the constant in front of the loop with the value 4 to 2 to get this properly working!

Edited by rolfk
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.

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.