From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

opal kelly constructors and LabWindows/CVI

Solved!
Go to solution

Hello, all.

 

I am trying to get an Opal Kelly XEM3005 board up and running with LabWindows/CVI 8.5.

 

I have been in touch with OK's Tech Suppt, and have run down the initial issues of "bool" types.  After having (at OK's recommendation) with "char" types, I can now include the headers without errors.

 

There is, however, a new problem:

 

When I call the constructor function, which should return a pointer to an "okFrontPanel_HANDLE" type, I am getting an error for a missing prototype for the constructor(s).

 

 

Dredging through the .c(pp)  file, I found the following:

//----------------------------

--------------------------------------------
// Function calls - okCFrontPanel
//------------------------------------------------------------------------
okDLLEXPORT okFrontPanel_HANDLE DLL_ENTRY
okFrontPanel_Construct()
{
    if (_okFrontPanel_Construct)
        return((*_okFrontPanel_Construct)());

    return(NULL);
}


However, trying to call it just gives me a "missing prototype" error.

Of course, doing some more dredging turned this up in the ".h" file:

//
// okFrontPanel
//
okDLLEXPORT okFrontPanel_HANDLE DLL_ENTRY okFrontPanel_Construct();
okDLLEXPORT void DLL_ENTRY okFrontPanel_Destruct(okFrontPanel_HANDLE hnd);


So I'm not sure I understand what's going on...  What is the horribly simple (and obvious) thing I am missing?

 

 

Relevent code snippets included below:
~~~~~~~~~~~~~~~~~~~~~~~~

try1.c:

 

#include <cvirte.h>        
#include <userint.h>
#include "Try1.h"
#include "XEM.h"
#include <windows.h>
//#define _WIN32

static int panelHandle;
static okFrontPanel_HANDLE    XEM_Device;

int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPSTR lpszCmdLine, int nCmdShow)
{
    if (InitCVIRTE (hInstance, 0, 0) == 0)
        return -1;    /* out of memory */
    if ((panelHandle = LoadPanel (0, "Try1.uir", PANEL)) < 0)
        return -1;
    DisplayPanel (panelHandle);
    RunUserInterface ();
    DiscardPanel (panelHandle);
    return 0;
}

int CVICALLBACK Connect (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    int    Value = 0;
    
    switch (event)
    {
        case EVENT_COMMIT:
            GetCtrlVal(PANEL, PANEL_CONNECT_SWITCH, &Value);
            SetCtrlVal(PANEL, PANEL_CONNECT_LED, Value);
            
            if( Value )
                XEM_Connect(XEM_Device);
            else
                XEM_Disconnect(XEM_Device);
            

            break;
    }
    return 0;
}

int CVICALLBACK Quit (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
            QuitUserInterface (0);
            break;
    }
    return 0;
}

 

~~~~~~~~~~~~~~~~~~

XEM.c:

 

int XEM_Connect ( okFrontPanel_HANDLE    XEM_Device )
{
    int    NoDevices = 0;    //    Number of devices attached to the PC
    
    //    Load the DLL (?)
    // Load the FrontPanel DLL
    if (FALSE == okFrontPanelDLL_LoadLib(NULL))
    {
        printf("Could not load FrontPanel DLL\n");
        exit(-1);
    }
    
    //    Find out how many devices are attached
//    XEM_Device = okFrontPanel_Construct();
    XEM_Device = okCFrontPanel();
//    NoDevices = okCFrontPanel();
    printf("%d OK devices attached\n", NoDevices);
    
    //    Call the contructor?    
//    okCFrontPanel ();
    return XEM_SUCCESS;
}


int XEM_Disconnect ( okFrontPanel_HANDLE    XEM_Device )
{
    
    //    Call the Destructor (?)
//    ~okCFrontPanel ();
    return XEM_SUCCESS;
}

Download All
0 Kudos
Message 1 of 4
(3,465 Views)
Solution
Accepted by topic author tomii

Hi tomii,

 

It looks like you posted another very similar thread about compiling errors with your Opal Kelly dll's here. I will be following up in that thread to help get some traction with these issues.

James W.
Applications Engineer
National Instruments
Message 2 of 4
(3,440 Views)

Well, I started this new one to give more info, as things have progressed some, and the answers I was getting in the other were not especially helpful.

 

Right now I'm at a linking problem (I think)

0 Kudos
Message 3 of 4
(3,437 Views)

Let me rephrase.  Yes, there is a new thread with much more recent info in it.  Sorry for the confusion

0 Kudos
Message 4 of 4
(3,435 Views)