Call Library Function with C structure

I have been given a MS C++ DLL that I need to call from LabVIEW. The input (and output) to the DLL are pointers to "C" data structures.
The LabVIEW "Call Library Function" VI allows you to add input parameters and define their type (I.e. Numeric, Array, String, etc.) However, "C data structure" is not one of the options. Is there a way in LabVIEW to call/use a MS C++ DLL that requires a data structure as an input and returns a data structure as the output?

It is possible to pass structures to called DLLs in LabVIEW. Typically the structure will be passed through the means of a cluster. Please see the link below for more information on calling external code in LabVIEW.
Using External Code in LabVIEW
You can also find a great example VI on calling DLLs in the LabVIEW example finder. Search for the keyword DLL and open up Call DLL.vi. This example shows most of the common ways to pass data between LabVIEW and external code.
Regards,
Matt F
Keep up to date on the latest PXI news at twitter.com/pxi

Similar Messages

  • Using an external DLL with "Call Library Function"

    Hi!
    I am trying to use an external DLL which is used from Visualbasic & Delphi:
    http://www.keb.de/common/tools/KEBCOMDriver.zip
    the protKEB.dll accesses the serial port to control an KEB frequency
    inverter.
    Unfortunatly there is no prototype header file for the DLL (no help on that
    from KEB).
    I only have a VisualBasic example program which works with the DLL.
    (Unfortunatly I am no Visual basic expert)
    To initialize the com port I have to use the function: setprotproperties &
    getprotproperties
    they are declared as:
    'Setting the protocol properties
    'ctrl is a pointer to a data structure of type tProtProperty
    Declare Sub setprotproperties Lib "protkeb.DLL" (ctrl As Any)
    'Reading the protocol properties
    'ctrl is a pointer to a data structure of type tProtProperty
    'the desired protocol is entered in ctrl.prottype before calling
    Declare Sub getprotproperties Lib "protkeb.DLL" (ctrl As Any)
    and tProtProperty is:
    Public Type tProtProperty
    ProtType As Long 'Type of Protocol (tProt)
    TimeOut As Long 'ALL protocols
    Baudrate As Long 'ANSI, HSP5
    Comport As Long 'ANSI, HSP5
    Flag As Long 'ANSI, HSP5: 01 = Sendslow
    / IP: 01 = UDP
    Port As Long 'IPort number
    Txtlen As Byte 'IP : length of following
    text or 0
    txt As String * 100 'IP : IP-Address or name
    (maximum length)
    End Type
    I already tried to use a cluster with tProtProperty entries as an Input for
    the function
    setprotproperty in a call library function with:
    Parameter Type : Adapt to type
    Data Format: Pointer to Handle
    but I always get an "exception within external code....."
    What am I doing wrong?
    How does a cluster & a "call library function node" look like that works?
    Any help is really appreciated!
    thanks
    tom
    ,-Thomas Kerberger Physikalisch-Technische Bundesanstalt-.
    | Abbestr.2-12 D-10587 Berlin fon: +49-30-3481338 |
    | mailto:[email protected] fax: +49-30-3481386 |
    `--------Labor 7.33 Messung thermischer Energie---------'

    Thomas,
    LabVIEW cannot call a DLL that has structures directly, you will need to create either a wrapper DLL or CIN that will take in all of the data individually construct the structure, and send it to the DLL function.
    For more information on what a cluster looks like in native code, I would suggest creating a simple cluster, creating a Call Library Function Node on the block diagram with a cluster input. Then right-click on the Call Library Function Node and choose "Create .c file". This will generate the data structure for the cluster and give you a better feel for it. I would then suggest going to the Using External Code in LabVIEW manual that can be found in the LabVIEW Bookshelf (Start»Programs»National Instruments»LabVIEW 6»LabVIEW Manuals or »LabV
    IEW 6.1»Search the LaBVIEW Bookshelf).
    There is also the following: Developer Zone: Passing a Variety of Data Types from DLL to LabVIEW.
    Randy Hoskin
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • Probel with call library function: I have a dll based on a complicated struct data type. How can I pass this structure?

    The data type is
    typedef enum {false, true} bool;
    typedef float flt4;
    typedef double flt8;
    typedef int i32s;
    typedef unsigned int i32u;
    typedef short int i16s;
    typedef unsigned short i16u;
    typedef signed char i08s;
    typedef unsigned char i08u;
    struct t_UnwrapData {
    struct {
    i08u flags;
    i16u unwrap_m;
    i08u weight_m;
    } status;
    flt4 *ph2pi;
    flt4 *weight;
    flt4 *gamma;
    flt4 *phase;
    i08u *flags;
    i08u *neigh;
    i32s neighOfst[8];
    i32s r,c;
    i32s x0,y0,xSz,ySz;
    flt8 unwTime;
    flt4 binCut;
    Please Could someone help me suggesting how I pass this dat
    a type to call library function?

    Hi Setu,
    Here is a solution that I have been playing to return back an array of clusters
    typedef struct
    int32 dimSize;
    uInt8 array[1];
    } LVU8;
    typedef LVU8 **LVU8Hdl;
    typedef struct
    U32 DeviceId;
    U32 VendorId;
    U32 BusNumber;
    U32 SlotNumber;
    LVU8Hdl SerialNumber;
    } LVDEVICE_LOCATION;
    typedef LVDEVICE_LOCATION **LVDEV_LOC_HANDLE;
    typedef struct
    int32 dimSize;
    LVDEVICE_LOCATION cluster_array[1];
    } LVDEV_LOC_ARRAY;
    typedef LVDEV_LOC_ARRAY **LVDEV_LOC_ARRAY_HANDLE;
    LVPLX_API void GetAllDevices(LVDEV_LOC_ARRAY_HANDLE cluster_array)
    int i,j;
    int numDevices = 3;
    DSSetHandleSize(cluster_array, sizeof(int32)+3*(sizeof(LVDEV_LOC_ARRAY)+(sizeof(int32)+16*sizeof(L
    VU8))));
    (*cluster_array)->dimSize = 3;
    (*((*cluster_array)->cluster_array[0]).SerialNumber)->dimSize =16;
    (*((*cluster_array)->cluster_array[1]).SerialNumber)->dimSize =16;
    (*((*cluster_array)->cluster_array[2]).SerialNumber)->dimSize =16;
    for(i=0; i<3; i++)
    ((*cluster_array)->cluster_array[i]).BusNumber = i;
    ((*cluster_array)->cluster_array[i]).VendorId = i*5;
    for(j=0;j<16;j++)
    (*((*cluster_array)->cluster_array[i]).SerialNumber)->array[j] = (10*j)+i;
    The code doesnt do much but returns back 3*cluster which the array in my cluster is sized for 16. The problem I've been having , was ensuring I have allocated enough memory to handle the complete structure. This works for me, now all I have to do is put the real code in which get my array of data from the instruments.
    Hope it helps
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Call library function node with array of clusters using array data pointer

    Hello all.
    I am writing a LabVIEW wrapper for an existing DLL function.
    The function has, as one of its parameters, an array of structs.  The struct is very simple, containing two integers.  I am using the call library function node to access it.
    In Labview I created an array of clusters, where the cluster has two 32-bit integers as its members.  So far, so good.
    Now I have to pass this in to the Call Library Function Node.  Here I am running into trouble.
    I have used The topic in LAVA and The topic in the knowledge base as my primary sources of information, though I have read a bunch of forum topics on the subject too.
    I do understand that I could write a new function which takes as a parameter a struct with the size as the first member and an array as the second, and I might just do this and have it call the regular function, but I was hoping to do it more simply.
    According to the C file which LabVIEW generates for me from the CLFN when I choose "Adapt to Type" and "Array Data Pointer", the prototype it is expecting is:
    int32_t myFunc(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, void data[], int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex);
    And the prototype of the function in my DLL is
    int borland_dll myFunc(DWORD handle, usint channel,
    int FIFOnumber, struct mStruct *data, int numWords, int *actualLoaded, int *actualStartIndex);
    This looks like a match to me, but it doesn't work (I get garbage in data).  From the topic in LAVA referenced above, I understood that it would work.  It does not.
    If I cast data to the pointer-to-pointer I get when I generate c code by wiring my struct to a CIN and generating, then I seem to get what I expect. But this seems to work when I choose "pointers to handles" too, and I would expect array data pointer to give a different result.
    Is there any way to get this to work directly, or will I have to create a wrapper?  (I am currently using LabVIEW 2011, but we have customers using 2009 and 2012, if not other versions as well).
    Thank you.
    Batya
    Solved!
    Go to Solution.

    OK, here is more detailed information.
    I have attached the VI.
    This is the code from the  "C" file created by right-clicking the CLN and creating a "C" file. 
    When the parameter in the CLN is set to "array data pointer":
    /* Call Library source file */
    #include "extcode.h"
    int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, void data[], int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex);
    int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, void data[], int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex)
    /* Insert code here */
     When the parameter is "pointers to handles":
    /* Call Library source file */
    #include "extcode.h"
    /* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */
    #include "lv_prolog.h"
    /* Typedefs */
    typedef struct {
    int32_t control;
    int32_t data;
    } TD2;
    typedef struct {
    int32_t dimSize;
    TD2 data[1];
    } TD1;
    typedef TD1 **TD1Hdl;
    #include "lv_epilog.h"
    int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex);
    int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex)
    /* Insert code here */
     When the parameter is set to "handles by value":
    /* Call Library source file */
    #include "extcode.h"
    /* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */
    #include "lv_prolog.h"
    /* Typedefs */
    typedef struct {
    int32_t control;
    int32_t data;
    } TD2;
    typedef struct {
    int32_t dimSize;
    TD2 data[1];
    } TD1;
    typedef TD1 **TD1Hdl;
    #include "lv_epilog.h"
    int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex);
    int32_t Load_Transmit_FIFO_RTx(uint32_t handle, uint16_t channel,
    int32_t FIFOnumber, TD1Hdl *data, int32_t numWords, int32_t *actualLoaded,
    int32_t *actualStartIndex)
    /* Insert code here */
    As to the DLL function, it is a bit more complicated than I explained above, in the current case.  My VI calls the function by this name in one DLL, and that DLL loads a DLL and calls a function (with the same name) in the second DLL, which does the work. (Thanks Rolfk, for helping me with that one some time back!)
    Here is the code in the first ("dispatcher") DLL:
    int borland_dll Load_Transmit_FIFO_RTx(DWORD handle, usint channel, int FIFOnumber, struct FIFO_DATA_CONTROL *data, int numWords, int *actualLoaded, int *actualStartIndex)
    t_DispatchTable *pDispatchTable = (t_DispatchTable *) handle;
    int retStat = 0;
    retStat = mCheckDispatchTable(pDispatchTable);
    if (retStat < 0)
    return retStat;
    if (pDispatchTable->pLoad_Transmit_FIFO_RTx == NULL)
    return edispatchercantfindfunction;
    return pDispatchTable->pLoad_Transmit_FIFO_RTx(pDispatchT​able->handlertx, channel, FIFOnumber, data, numWords, actualLoaded, actualStartIndex);
    borland_dll is just "__declspec(dllexport)"
    The current code in the DLL that does the work is:
    // TEMP
    typedef struct {
    int control;
    int data;
    } TD2;
    typedef struct {
    int dimSize;
    TD2 data[1];
    } TD1;
    typedef TD1 **TD1Hdl;
    // END TEMP
    int borland_dll Load_Transmit_FIFO_RTx(int handlertx, usint channel, int FIFOnumber, struct FIFO_DATA_CONTROL *data, int numWords, int *actualLoaded, int *actualStartIndex){
    struct TRANSMIT_FIFO *ptxFIFO; //pointer to transmit FIFO structure
    usint *pFIFOlist; //pointer to array of FIFO pointers to FIFO structures
    int FIFOentry, numLoaded;
    usint *lclData;
    usint nextEntryToTransmit;
    // TEMP
    FILE *pFile;
    int i;
    TD1** ppTD = (TD1**) data;
    TD1 *pTD = *ppTD;
    pFile = fopen("LoadFIFOLog.txt", "w");
    fprintf(pFile, "Starting Load FIFO with %d data words, data pointer 0x%x, with the following data&colon; \n", numWords, data);
    for (i = 0; i < numWords; i++) {
    fprintf(pFile, "%d: control--0x%x, data--0x%x \n", i, data[i].control, data[i].data);
    fflush(pFile);
    fprintf(pFile, "OK, using CIN generated structures: dimSize %d, with the following data&colon; \n", pTD->dimSize);
    for (i = 0; i < numWords; i++) {
    fprintf(pFile, "%d: control--0x%x, data--0x%x \n", i, pTD->data[i].control, pTD->data[i].data);
    fflush(pFile);
    // END TEMP
    if ((handlertx) <0 || (handlertx >= NUMCARDS)) return ebadhandle;
    if (cardrtx[handlertx].allocated != 1) return ebadhandle;
    pFIFOlist = (usint *) (cardrtx[handlertx].segaddr + cardrtx[handlertx].glob->dpchn[channel].tr_stk_ptr​);
    pFIFOlist += FIFOnumber;
    ptxFIFO = (struct TRANSMIT_FIFO *)(cardrtx[handlertx].segaddr + *pFIFOlist);
    //use local copy of ptxFIFO->nextEntryToTransmit to simplify algorithm
    nextEntryToTransmit = ptxFIFO->nextEntryToTransmit;
    //on entering this routine nextEntryToLoad is set to the entry following the last entry loaded
    //this is what we need to load now unless it's at the end of the FIFO in which case we need to wrap around
    if ( ptxFIFO->nextEntryToLoad >= ptxFIFO->numEntries)
    *actualStartIndex = 0;
    else
    *actualStartIndex = ptxFIFO->nextEntryToLoad;
    //if nextEntryToLoad points to the last entry in the FIFO and nextEntryToTransmit points to the first, the FIFO is full
    //also if nextEntryToLoad == nextEntryToTransmit the FIFO is full and we exit without loading anything
    if (( (( ptxFIFO->nextEntryToLoad >= ptxFIFO->numEntries) && (nextEntryToTransmit == 0)) ||
    ( ptxFIFO->nextEntryToLoad == nextEntryToTransmit)) && (ptxFIFO->nextEntryToLoad != INITIAL_ENTRY)){
    *actualLoaded = 0; //FIFO is full already, we can't add anything
    return 0; //this is not a failure, we just have nothing to do, this is indicated in actualLoaded
    numLoaded = 0;
    lclData = (usint *)data; //must use 16 bit writes to the module
    //conditions are dealt with inside the for loop rather than in the for statement itself
    for (FIFOentry = *actualStartIndex; ; FIFOentry++) {
    //if we reached the end of the FIFO
    //if the module is about to transmit the first element of the FIFO, the FIFO is full and we're done
    //OR if the module is about to transmit the element we're about to fill in, we're done - the
    //exception is if this is the first element we're filling in which means the FIFO is empty
    if ((( FIFOentry >= ptxFIFO->numEntries) && (nextEntryToTransmit == 0)) ||
    ((FIFOentry == nextEntryToTransmit) && (FIFOentry != *actualStartIndex) )){
    *actualLoaded = numLoaded;
    //set nextEntryToLoad to the end of the FIFO, we'll set it to the beginning next time
    //this allows us to distinguish between full and empty: nextEntryToLoad == nextEntryToTransmit means empty
    ptxFIFO->nextEntryToLoad = FIFOentry;
    return 0;
    //we reached the end but can continue loading from the top of the FIFO
    if ( FIFOentry >= ptxFIFO->numEntries)
    FIFOentry = 0;
    //load the control word
    ptxFIFO->FifoData[FIFOentry * 3] = *lclData++;
    //skip the high of the control word, the module only has a 16 bit field for control
    lclData++;
    //now put in the data
    ptxFIFO->FifoData[(FIFOentry * 3) + 2] = *lclData++;
    ptxFIFO->FifoData[(FIFOentry * 3) + 1] = *lclData++;
    numLoaded++;
    //we're done because we loaded everything the user asked for
    if (numLoaded >= numWords) {
    *actualLoaded = numLoaded;
    ptxFIFO->nextEntryToLoad = FIFOentry+1;
    return 0;
    //if we reached here, we're done because the FIFO is full
    *actualLoaded = numLoaded;
    ptxFIFO->nextEntryToLoad = FIFOentry;
    fclose (pFile);
    return 0;
     As you can see, I added a temporary diagnostic with the structures that were created in the "Handles by value" case, and print out the data.  I see what is expected, whichever of the options I pick in the CLN!  
    I understood (from the information in the two links I mentioned in my original post, and from the name of the option itself) that "array data pointer" should pass the array of data itself, without the dimSize field.  But that does not seem to be what is happening.
    Batya
    Attachments:
    ExcM4k Load Transmit FIFO.vi ‏15 KB

  • Using Call Library Function Node To Return C++ Structure Informatio​n

    Hi everyone.  This question is for all you LabVIEW gurus out there.
    I am trying to call a function from a .dll to get information from a structure about a device (FT232H chip).  I am using the "Call Library Function Node" to do this in LabVIEW.  My issue is I do not know how to set up the "Call LIbrary Function Node" parameter for a C++ structure.  How do I set up the pointer to FT_DEVICE_LIST_INFO_NODE structure using the "Call Library Function Node" so that I can read back the device information?
    The details of the C++ function and the structure are below.
    Thanks for everyone's help!
    The C++ function is the following:
    FT_STATUS I2C_GetChannelInfo (uint32 index, FT_DEVICE_LIST_INFO_NODE *chanInfo)
    In = index (Index of the channel)
    Out = *chanInfo (Pointer to FT_DEVICE_LIST_INFO_NODE structure)
    The pointer to the FT_DEVICE_LIST_INFO_NODE is defined as:
    typedef struct _FT_DEVICE_LIST_INFO_NODE {
    ULONG Flags;
    ULONG Type;
    ULONG ID;
    DWORD LocId;
    char SerialNumber[16];
    char Description[64];
    FT_HANDLE ftHandle;
    } FT_DEVICE_LIST_INFO_NODE;

    Dennis/Nathan,
    I tried to set up the "Call Library Function Node (CLFN)" correctly in order to read out Device Information from a FTDI Chip (FT232H) but when I run the VI LabVIEW crashes on me always.
    I have attached the code.  For the FT_DEVICE_LIST_INFO_NODE structure I passed into the "CLFN" a constant cluster of all the structure elements and then I set up the node to:
    Type: Adapt to Type
    Data format: Handles by Value
    I think LabVIEW crash may have something to do with the fact that the output of the dll function is using a pointer to a structure.  With the Handles by value Data format I am unable to set the Pointer to structure.
    Can you please take a quick look at the code to see if I am setting the CLFN up correctly?
    Thanks!
    Once again, here are the C++ Code Details:
    FT_STATUS I2C_GetChannelInfo (uint32 index, FT_DEVICE_LIST_INFO_NODE *chanInfo)
    In = index (Index of the channel)
    Out = *chanInfo (Pointer to FT_DEVICE_LIST_INFO_NODE structure)
    The pointer to the FT_DEVICE_LIST_INFO_NODE is defined as:
    typedef struct _FT_DEVICE_LIST_INFO_NODE {
    ULONG Flags;
    ULONG Type;
    ULONG ID;
    DWORD LocId;
    char SerialNumber[16];
    char Description[64];
    FT_HANDLE ftHandle;
    } FT_DEVICE_LIST_INFO_NODE;
    Attachments:
    FT_I2C_GetChannelInfo.vi ‏14 KB

  • Passing arrays with Call Library Function does not work after application builder

    Calling a DLL with Call Library Function which requires an array of data works correctly in Labview, but after building an exe with application builder, the call no longer works.  Dereferecing the pointer in the DLL retuns all 0s and not the actual values.
    Solved!
    Go to Solution.
    Attachments:
    TEST.zip ‏28 KB

    I did not run your code because it is a little unclear to me what it does.
    Two things:
    First, is the DLL you are calling the DLL-ified version of PopUpNames.vi? Then the problem is likely that the panel is not being built into the DLL.
    When LabView builds an application / dll, it strips the front panel and block diagram from all VIs that it doesn't think need to show a panel at run time. This reduces file size and increases code security. The App Builder's panel inclusion logic can be overridden by Build Specifications -> Source File Settings -> Remove front panel. A better method is to put a property node on a control in a window you want to show marking it "visible"; this is sufficient to tell the App Builder it should keep the panel.
    Currently Source File Settings shows "no dependencies" (clearly incorrect---another evil side effect of Express VIs I guess) but if you change the settings as shown below to keep ALL panels, one might hope the App Builder can figure it to keep the panel when it deconstructs the Express VI. (Alternatively convert the Express VI into a regular one.)
    A second comment: I am a bit flummoxed at the larger goal here. You are calling LabView DLL from LabView, which doesn't make a lot of sense, so I assume your larger goal is to call LabView from C or vice-versa. In that case be aware that your DLL is x86 (32-bit) but you are passing 64-bit ints as your pointers. In this case it is 32-bit LabView with 32-bit pointers in embedeed in 64-bit containers calling 32-bit LabView with 32-bit pointers in embedeed in 64-bit containers, so it all works, but if your going to call this from C or whatnot you're going to have to follow that same design.
    When calling C code the LabView Call Library Function does have a "unsigned pointer-sized integer" data type that always appears to be 64 bits in the dev env but which actually passes a 64 or 32-bit int to the DLL depending on the environment. The "pointer sized int" has to be 64 bits in the "LabView" part of the code because LabView's strong typing requires the data type to be determined at compile time. Casting all pointers to the largest data type in LabView makes it possible to write platform-independent code, but down at the Call Library level you still have to put the right number of bytes on the stack.

  • Problem with Call Library Function. Want to pass a string and return a string, but my compiler does not recognize "CStr" and Labview does not recognize my "char *function()" callout

    Hi, I'm trying to use a .DLL I wrote in Visual C++ .NET. The Call Library Function generates a function prototype of "CStr Parser(CStr arg_raw)"
    but my compiler won't accept this. So I change it to how C normally deals with strings "char *Parser(char *arg_raw). Now the Call Librafy Function does not find "Parser" in my .DLL though it is definitely there!
    Help!
    -Fong

    Hello
    You will need to include extcode.h in your C file. You can find this under ..\LabVIEW\cintools folder.
    The include has all the defines you will need.
    Bilal Durrani
    NI
    Bilal Durrani
    NI

  • Call multiple functions from same dll with call library function

    hi,
    i am working on a project in wich we need to make a UI to read out a sensor network.
    the UI should be usable in any project, but every node needs a different piece of code depending on the type of sensor with wich it is equipt.
    so i need to be able to call different pieces of code when i need them, and still be able to use the UI in future projects with possibly new types of node we now don't have.
    so someone told me to use DLL's, cause then i would be able to call the code i need the moment i need it.
    but i have never worked with DLL's (just learned about this option 3 day's ago) so i have a question.
    i know i can dynamicly change the DLL i call with the call library function, but can i dynamicly change the function i call from that DLL ?
    or do i have to put a new call library function for each function i want to call, even if its from the same DLL ?
    kind regards,
    stijn

    nazarim wrote:
    ok so there is no (easy and ubderstandable) way for me to dynamicly change wich function i want to call from a certain DLL.
    but now i started wondering, the path on the call library function is not ment to dynamicly change a DLL
    but it does work so, if i am carefull, can i use it for that purpose or will labview give me a series of problems once i start using it in larger programs ?
    Thepath on the Call Library Node can be used to load a different DLL. Obviously since you can't change the function name your other DLL would have to export exactly the same function name and of course with the same parameters. This is seldom the case so it is not the main use of the path input to the Call Library Node. It's main use is as indicated to load DLLs at runtime rather than at load time of a VI. So that an application can run even when the DLL is missing, until the moment the functionality from that DLL is needed.
    If you can make sure that all your DLLs export the same function name with the same parameter you can use the Call Library Node to call into different DLLs through the path input. If however you would need to call different function names you would have to resolve to some DLL which does do the dispatching and invocation using LoadLibrary() and GetProcAddress(). But unless you need to go with DLLs for some reason using the Call By Reference Node can give you an even more flexible approach. 
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • VI analyzer: Wire under object test fails with Call Library Function Nodes

    Hi,
    If I wire a Call Library Function Node with an ErrorIn and an ErrorOut, the VI Analyzer Test "Wire under Object" fails always with two occurrences per Call Library Function Node.
    A double click to the occurrence highlights the error lines connected with the call... node.
    The test does not fail, if the error lines are not connected.
    Thanks!
    H
    Solved!
    Go to Solution.

    This became a problem when Call Library Nodes got error terminals (and optional path terminals) in LabVIEW 8.20.  I should be able to get a fix in to VI Analyzer Toolkit 2010.
    Thanks for taking the time to report the bug.
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Pointer to struct in call library function

    I have a dll function with this prototype:
    DWORD CAN_Read(TPCANMsg* pMsgBuff);
    where TPCANMsg is a structure.
    typedef struct{
    DWORD ID;
    BYTE MSGTYPE;
    BYTE LEN;
    BYTE DATA[8];
    }TPCANMsg;
    I create a cluster that is represented as a structure. But in Call Library Function witch do I have to choose: "Handles by Value" or "Pointers to Handles"?

    > I have a dll function with this prototype:
    > DWORD CAN_Read(TPCANMsg* pMsgBuff);
    > where TPCANMsg is a structure.
    > typedef struct{
    > DWORD ID;
    > BYTE MSGTYPE;
    > BYTE LEN;
    > BYTE DATA[8];
    > }TPCANMsg;
    > I create a cluster that is represented as a structure. But in Call
    > Library Function witch do I have to choose: "Handles by Value" or
    > "Pointers to Handles"?
    The key is to make sure the type is set to Adapt. The setting of the
    Data Format shouldn't matter since your datatype doesn't have a string,
    array, path, or other nonflat data element.
    for the DATA[8], you will want to use eight inline U8s, or a cluster of
    the bytes.
    The info I'm going on is the LV External Code manual.
    Greg Mckaskle

  • Call library function inside a conditiona​l disable bug

    i'm trying to call a function in a dll using the call library function inside a conditional disable structure.
    one of the parameters is a pointer to a C structure.
    here is the prototype:
    short in myfunction(short in DevNum, void *pMetrics);
    outside of the conditional disable, LabVIEW allows me to wire the pMetrics parameter to a cluster.
    if i put the function inside the conditional disable, LabVIEW doesn't allow me to wire it.
    as a workaround, i put the cluster inside the conditional disable as well.
    any ideas?

    Simply create a constant of the cluster and and put it outside the disable structure. Wire this constant to all inputs (left side terminal) of the Call Library Node. A Call Library Node (CLN) set to Adapt to Type does need a valid datatype to adapt too. This works from the outside side (right side terminal) of the CLN only if the according indicator is inside the same data structure. In older LabVIEW versions you actually had to always define the left side by wiring a constant or a dummy control to it.
    This has to do with the algorithme that evaluates datatypes along wires. Making that algorithme go backwards (against the natural dataflow) inside one subdiagram without causing circular references or similar is already a challange. Doing that across diagram boundaries (case, disable, loop, etc. structures) is basically impossible without causing the entire edit operation to get very slow.
    Message Edited by rolfk on 10-20-2009 08:28 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • The call library function require us to define the type of parameter that w are using.The type of parameter in cludes numeric, array, string,wav​eform and adapt to type.I would like to know more about waveform and adapt to type.

    In the labview manual, there is very little mention about the use of waveform.How is this waveform being called and can i have an example to see how this work.
    Also in the adapt to type paramete, what does this parameter do and in what circumstances do we need to use it.The manual say something about the use of this parametr.It says that scalar elements in arrays or clusters are in line.For example a cluster containing anumeric is passed as pointer to a structure containing a numeric. What does this statement mean?
    Can i imply t
    hat if my input is a struct, can i use a adapt to type parameter to overcome this incompatibility?Can i also have an example to let me have a better idea.thank you

    I'm going to share my experience with the "Adapt to Type" parameter.
    Attached to this message is an example. The attachment is a zip file with three files: a dll, a c file and a vi written in LabVIEW 6. The dll contains a function that return a structure with 3 values (like the coordinates of a point in space, that is, (x, y, z)). You can see how the function was constructed by looking at the c file.
    In LabVIEW, I created a cluster with the same three parameters. Then, I configured the call library function following the function prototype as in the c file. For the point variable I use "Adapt to Type".
    I hope this can give you a head star.
    Best regards;
    E. Vargas
    www.vartortech.com
    Attachments:
    pointexample.zip ‏63 KB

  • How to call a C pointer from call library function node

    I have a client/server application which the client I am trying to develop using Labview.  When I use to communicate the server and the client using the program provided by the manufacter, the system works perfectly.
    Now, I am trying to develop a system using labview, because I need to get another things.
    I have the DLL provided by the manufacter and the .h too, so I can check the functions parameters. One of these functions needs to be called using a struct element. Probably, the function's DLL instantiates the elements of this struct.  I use the call library function node to do it.
    When I receive the data, the function returns to me the struct that I passed as a parameter before, and then I can read all the elements of the struct, except the string element that returns nothing. The struct elements that are numerical, I can read them perfectly.
    Another thing that is important to say, is that the string data was not returned in fact by the DLL function that the system calls. I have to pass a pointer (I use it as unsigned 16 in Labview, but I tried before as string and unsigned 8) as a parameter, and this pointer will point to the memory location that the string is. When I try to read what is returned by the function, I can read nothing. The same function returns that the size of data that is returning is 17 bytes.
    How can I solve it?
    Thank you in advance

    Did you take a look at the example that ships with LabVIEW that shows how to do all sorts of data passing to DLLs. I believe your situation is one of the examples listed. You can find the example VI in the "<LabVIEW install directory>\examples\dll\data passing" directory.

  • How can I debug the Call Library Function at run-time

    I've written a VI using the CLF to call a DLL which was compiled off-site by another engineer using MSVC. Even though the VI runs without flagging any errors, the VI is not doing what I expect. Is there any way of finding out if the DLL is been called correctly? The first function that is called doesn't return any value, but I think that it should. Does this mean that the DLL is not being called correctly? Note also that the DLL works fine with a JAVA GUI.

    Make sure that you are specifying the proper function prototype in the call library function. If you are slightly off the call will not work properly. Ask the offsite engineer to provide you with this data. Another tip is to build the dll with the option to show front panel when called. You can actually popup the dll like you would a subvi. If you design it with test indicators showing on the front panel that is a great way to determine if it is working. Hope this helps.
    BJD1613
    Lead Test Tools Development Engineer
    Philips Respironics
    Certified LV Architect / Instructor

  • PDA: Calling library functions - seems to link the stubbed .cpp file instead of the DLL

    I'm having trouble developing a Lab View PDA module that calls a DLL built using Visual C++. The DLL functions correctly when called in a non-PDA VI. My issues seem to be with porting to the PDA.
    My configuration:
    - Lab View 8.5 with the PDA 8.5 module
    - Visual Studio 8.0 with the Windows Mobile 6.0 SDK
    - ASUS 626 PDA with an Intel PXA70 procesor running Windows Mobile 6 Classic
    Following the PPCBatt example code provided with the PDA module, I have:
    - used extern "C" to prevent name mangling
    - placed the DLL built with the Windows Mobile SDK in the \Windows directory on the PDA
    - created a stub Win32 DLL and lib
    - created a stubbed cpp file whose functions only return zero
    - included the stubbed cpp and lib files in the build spec / source files / additional files
    - placed Call Library Function nodes on my PDA VI, selected the function names, set the parameter types
    - built and deployed the executable, both with and without debug
    When I set the library path property of the Call Library Node, the functions appeared in the function name pulldown, but the parameters did not populate. I had to manually add them and set their types. The help page says they would autopopulate when the function was selected.
    I've debugged the VI, and the Library Function Call nodes are being called. It seems the build is linking the code from the stub C file provided in the additional files portion of the source files property page, instead of adding hooks to call the DLL on the PDA. As a test, I changed an output parameter in one of the functions in the stubbed cpp file - the changed value showed in the front panel indicator.
    What am I doing wrong?
    Dan

    Hi Dan,
    I'm not sure if I understood you problem fully. When calling external code with LabVIEW PDA, the DLL acts as a stub DLL with the correct function prototypes for the C code that you want to call. Here's a Knowledge Base article that might help explain about calling External Code in LabVIEW PDA.
    Regards,
    Stanley Hu
    National Instruments
    Applications Engineering
    http://www.ni.com/support

Maybe you are looking for

  • Mega 865

    I have MSI Mega 865 P4 2.8 GHz (800MHz) Apacer 256 MB RAM (400HMz) ATI Radeon 9550 MSI Mega TV Tuner Card WD 160GB SATA WinXP (SP1) and Media Center Deluxe III everything working properly, but: if I got change TV chanel in Media Center - freeze whole

  • How to create variable

    hi there i sthere anyway else then query designer that i can create my variable.i guess there must be some way else. please advise

  • Creating a common workspace under OS X

    I thought this would be simple, but I'm having trouble coming up with an answer. I have several people who will be using a single Mac to do their work, and they would like to have a way of sharing read/write access to certain files. I thought I could

  • JTable: set different cellEditors for cells within a column

    I have a table that there could be different class types within the same column, such as Integer, String. How could I invoke different editors based on the class type from the cell? I would appreciate it for your help. -fs

  • WindowServer crashing upon going to sleep...?

    After a few instabilities updating to ML (largely caused by Flash, or at least I can blame it as a convenient scapegoat) that cost me my saved Chrome tabs, I notice that every time I wake my computer up from sleep, a number of applications appear to