Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
3 ratings:
 3 out of 5   

Passing Structured Data Types Between TestStand and a LabVIEW DLL



Primary Software:
Primary Software Version: 3.0
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW Run-Time Engine

Problem:
I have created several LabVIEW code modules to be called from TestStand. These VIs take clusters for their inputs and outputs. When I call the VIs directly with the LabVIEW adapter, it is very easy. However, I have compiled my VIs into a DLL, and I can't seem to figure out how to call the DLL in TestStand and still pass in the VI clusters correctly. How can I do this?

Solution:
The first thing to check is to make sure the LabVIEW DLL was built with the standard calling convention. This option is set when building the DLL within LabVIEW. For more information on building LabVIEW DLLs, see the tutorial in the related links section.

The next step in communicating with the LabVIEW DLL is to define a custom data type for the clusters being passed to the DLL. In general, inside TestStand, LabVIEW clusters are represented as a container, and a custom data type (container) must be defined for each cluster. Follow the steps below to create a custom data type for the LabVIEW cluster:

First, the LabVIEW DLL must be built with the standard calling convention to be interpreted properly within TestStand. Define a structured type in TestStand for each cluster type that needs to be passed to/from the DLL. You can do this by creating a new type in the Custom Data Types section of the Sequence File Types view or in a Type Palette.  Create the TestStand container and the data types within the container.  In the Properties window of your structured types, you need to configure the C Struct Passing tab:
  1. Right-Click on the newly created type, select Properties, and Select the C Struct Passing tab
  2. Check the Allow Objects of This Type to be Passed as Structs
  3. Change the Packing to 1 Byte Boundary
    1. Choose the 1 byte boundary for the packing,
    2. Select the appropriate type for each property:
      • LabVIEW String for a string,
      • Unsigned 8-bit integer for a boolean,
      • LabVIEW Array for an array.

Create a C/C++ DLL step to call your LabVIEW DLL and specify the module to call. In the Edit C/C++ DLL Call window,
  1. Select the LabVIEW DLL.
  2. Select the name of the function to call; a popup message informs you that no information about the function prototype was found.
  3. Edit the prototype by adding parameters. For each structured typed parameter (each cluster) select:
    • C Struct for the Category parameter.
    • Your custom structured type for the Type parameter.
    • By Pointer (*) for the Pass parameter.

You can refer to the StructPassing example provided with TestStand if you need help. This example demonstrates how to pass a TestStand container as a LabVIEW cluster to a LabVIEW function. The container used is composed of several different data types. The LabVIEW VIs are compiled into a DLL and called as functions. Be aware that LabVIEW VIs always use a 1 byte packing scheme when passing clusters as parameters. Refer to the StructPassing TestStand shipping example located at <TestStand>\Examples\StructPassing\LabVIEW for further information.

Related Links:
KnowledgeBase 3KPBEO73: Calling Functions, in a C/C++ DLL, that have a C Struct as a Parameter from TestStand
Developer Zone Tutorial: Building DLLs in LabVIEW 6.x or later

Attachments:





Report Date: 05/31/2006
Last Updated: 07/02/2008
Document ID: 3XU5DUDO

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit