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: 

How to pass a pointer in labview library call function by using dll programmed in Labwindows?

Solved!
Go to solution

Hi,

I'm trying to interface a camera with Labview.  However, the camera can only be programmed by C, so I'm using Labwindow CVI.

I need to pass a camera handle from one function to another, eg. from a opencamera function to setparameter function.  

 

/* Load the Qcam driver and Open the First Camera */
void DLLEXPORT LoadDriverAndOpenCamera()
{
QCam_CamListItem cameraList[10];
unsigned long cameraListLength=sizeof(cameraList)/sizeof(cameraList[0]);

//load the driver
QCam_LoadDriver();
//get a list of the cameras
QCam_ListCameras(cameraList,&cameraListLength);
//listLength is now the number of cameras available

QCam_Handle hCam;
//Open the first camera in the list
QCam_OpenCamera(cameraList[0].cameraId, &hCam);
}

 

Apparently, caemraId is an unsigned long (unsigned 32-bit in Labview 2012 32-bit? ) and QCam_Handle is defined as void*, so it's a pointer that points to an unsigned 32-bit.

When I only use C for programming, I can pass hCam variable to other functions as long as it's declared as global variable.  Ex, the next function can be void SetParameter(QCam_Handle hCam).  However, here I'm trying to make a dll by Labwindows/CVI and then call LoadDriverAndOpenCamera() function through library call in Labview.  

 

My question is:  How can I pass hCam to other functions in the same dll?  Do I have to add paramter to the function? For example:

void DLLEXPORT LoadDriverAndOpenCamera(unsigned long cameraId, QCam_Handle* cameraHandle)

 

And then add two lines:

cameraId=cameraList[0].cameraId;
cameraHandle=hCam;

 

into the function?  Then I can pass cameraHandle out?  However, hCam will still have void* type.

 

Even if that's the case, how can I set up library call node on Labview?  In the arg parameter set up, I don't see pointers?  It seems I cannot set up an output node to be a pointer that points to a unsigned long.

 

Thank you very much for your help!

 

Best,

Charles

0 Kudos
Message 1 of 4
(4,717 Views)
Solution
Accepted by topic author soljiang

Hello Charles, 

 

I noticed you posted a similar question here. do you have any further questions about using the call library function node? 

0 Kudos
Message 2 of 4
(4,677 Views)

I think I got the answer for now.  Can one close a thread?  Thanks?

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

Sure thing! 

0 Kudos
Message 4 of 4
(4,660 Views)