Using LabWindows™/CVI™ Enums in TestStand

Updated Feb 23, 2026

Environment

Software

  • TestStand
  • LabWindows/CVI

You are developing a LabWindows™/CVI™ DLL that contains a function using an enumeration as one of its input parameters. You want to call this function from NI TestStand™ and have TestStand correctly recognize and display the enumeration values so they can be selected in step parameter dropdowns and mapped to custom data types.

 

This article explains how to define an enumeration in LabWindows™/CVI™, generate a corresponding function panel file (.fp), export it through a DLL, and configure NI TestStand™ to recognize and use the enumeration values.

 

 

Table of Contents

 

 

 

 

Create and build the LabWindows™/CVI™ DLL

 

Header and source code

 

  1. Create a LabWindows™/CVI™ project from a template.
    1. Select File » New » Project from Template…
    2. Name it CVI Enumeration Values and choose a convenient target location.
    3. A header file (.h) and a source file (.c) will be created and added to your project.
  2. Open the CVI Enumeration Values.h header file and paste the following code under the //Types section:

    /* Public enum (typedef with a name so CVI can put it in the type library) */
    typedef enum TestMode {
        TEST_MODE_SELF_TEST,        
        TEST_MODE_CALIBRATION,
        TEST_MODE_FUNCTIONAL,      
        TEST_MODE_ENV_STRESS,        
        TEST_MODE_BURN_IN,          
        TEST_MODE_FIRMWARE_UPDATE,   
        TEST_MODE_DIAGNOSTIC,       
        TEST_MODE_PRODUCTION_QA,     
        TEST_MODE_END_OF_LINE,       
        TEST_MODE_CUSTOM            
    } TestMode;
    

 

  1. In the same header file, add the following function declaration below //Global functions

    /// OUT
    int DLLEXPORT TestModeName(TestMode mode, char* buffer, unsigned int bufferSize);
    


    In the snippet above:

    • /// OUT 2 will be used to specify that char* buffer is an output parameter when generating the .fp file.
    • The DLLEXPORT macro ensures this function will be visible in TestStand.
  1. Open the CVI Enumeration Values.c source file and paste the following code under //Global Functions. The TestModeName() function will be called by TestStand:

    int TestModeName(TestMode mode, char* buffer, unsigned int bufferSize)
    {
        const char* name;
    
        if (!buffer || bufferSize == 0)
            return -2; /* no space to write even a null terminator */
    
        switch (mode)
        {
            case TEST_MODE_SELF_TEST:        name = "Self Test"; break;
            case TEST_MODE_CALIBRATION:      name = "Calibration"; break;
            case TEST_MODE_FUNCTIONAL:       name = "Functional"; break;
            case TEST_MODE_ENV_STRESS:       name = "Environmental Stress"; break;
            case TEST_MODE_BURN_IN:          name = "Burn-in"; break;
            case TEST_MODE_FIRMWARE_UPDATE:  name = "Firmware Update"; break;
            case TEST_MODE_DIAGNOSTIC:       name = "Diagnostic"; break;
            case TEST_MODE_PRODUCTION_QA:    name = "Production QA"; break;
            case TEST_MODE_END_OF_LINE:      name = "End of Line"; break;
            case TEST_MODE_CUSTOM:           name = "Custom"; break;
    	}
    
        /* Copy with truncation protection */
        if (strlen(name) + 1 > bufferSize)
        {
            /* truncate safely */
            strncpy(buffer, name, bufferSize - 1);
            buffer[bufferSize - 1] = '\\0';
            return -2; /* buffer too small */
        }
    
        strcpy(buffer, name);
        return 0;
    }
    

 

  1. Add #include <string.h> under the //include files section. Some functions used in TestModeName() come from this library.
  1. Select File >> Save All.

 

[Back to TOC]

 

Function Tree

 

  1. Open CVI Enumeration Values.h.
  1. Select Options » Generate Function Tree.... This tool automatically creates the function tree in a front panel file (.fp), which TestStand requires to correctly parse the enumerator values.

    Generate Function Tree... Menu item

  1. In the Generate Function Tree dialog, enter:
    1. Instrument Name - CVI Enumeration Values

    2. Default Qualifier - DLLEXPORT

    3. Output function tree - <path_to_cvi_project>\CVI Enumeration Values.fp

      Generate Function Tree dialog

  1. Click OK to generate the file.
  1. Select File >> Add CVI Enumeration Values.fp to Project.

 

[Back to TOC]

 

Build

 

  1. Ensure the build configuration matches the TestStand bitness by going to Build >> Configuration, and selecting one of the following options:
    • Debug
    • Release
    • Debug64
    • Release64
  1. Go to the Build >> Target Settings…
  1. Click Type Information…
    1. Check the Add type library resource to DLL option.

    2. Set Function panel file to the .fp file created earlier.

    3. Click OK to close the Type Information dialog.

      Type information

  1. Back to the Target Settings dialog, Click the Change… button in the Export section and select Symbols marked for export in the Export what dropdown.

    DLL Export Options

  1. Click OK to close the DLL Export Options dialog.
  1. Click OK to close the Target Settings dialog.
  1. Click Build >> Build (Ctrl+M) to build your DLL. It should build successfully.

    build status

 

[Back to TOC]

 

Integrate the DLL in Teststand

 

This section explains how to load the DLL into TestStand, configure a CVI Action step to call the exported function, and confirm that TestStand correctly identifies the function parameters and enumeration values. You will also create a custom TestStand enumeration type, map it to the function parameter, and use a TestStand variable to control the enum value passed to the function.

 

Configure the CVI Action step

 

  1. Create a new sequence file.
  1. Add a CVI Action step to the MainSequence and name it Get Test Name.
  1. In the Step Settings pane, select your DLL as the Module, and choose TestModeName as the function. The parameter list should populate automatically.
  1. TestStand automatically detects and displays the enumeration values in the mode parameter dropdown.

    Step settings pane

  1. Set the parameters as shown in the table below. At this point, you’ll need to create both Locals.Status and Locals.ModeName.
     

    ParameterValue ExpressionType
    Return ValueLocals.StatusNumeric
    modeTEST_MODE_ENV_STRESSTestMode (Enum) Constant
    bufferLocals.ModeNameString
    bufferSize1024Numeric Constant

 

  1. Add a breakpoint below the Action step and click Execute » Run MainSequence. Confirm that Locals.ModeName contains the expected text.

    Execution view showing Locals.ModelName with the "Environemnt Stress" value.

 

[Back to TOC]

 

Assign a variable to the Enum

 

  1. In the Step Settings pane, select the mode parameter and change the Category property from Numeric to Enumeration.

    Note: The mode parameter will show an error because the Enum Type hasn't been defined yet. You will fix this in the following steps.

  1. Click Create/Update Custom Data Type…

    mode parameter showing the Create/Update Custom Data Type... button

  1. Review the Create/Update Custom Data Type from Enum dialog. TestStand will create a new data type called TestMode in the CVI Enumeration Values.seq file. Click Create.

    Dialog showing the information about the enum that will be created.

  1. Click OK on the confirmation dialog.
  1. Now set Enum Type to TestMode. The previous error should no longer appear.

    mode parameter's properties

  1. Create a variable named Locals.Mode and set its type to TestMode.

    Creating a local variable of Type "TestMode"

  1. Set the mode parameter’s Value Expression to Locals.Mode.
  1. Run the MainSequence again. Now Locals.Name should display the name corresponding to the enum value stored in Locals.TestMode.

    execution view 

 

[Back to TOC]