LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating .lsb problem

Hi, I've been trying to learn how to use CINs in Labview and I'm working through the multiplication tutorial. I've read the manual on using CINs and read through various pages on this forum regarding the issue. I have tried multiple things: the CIN Custom Step.vi from this website, typing commands into cmd, editing the custom build in Visual C++, and creating a .mak file. yet none of these work, no matter what I try the dll is created successfully, the .lsb is created successfully, but when I try to load the code resource and run the VI it says that I have not loaded the code resource. Are there any other ways to do this, or might I have done something else wrong?
0 Kudos
Message 1 of 4
(2,987 Views)
I know this doesn't completely answer your question but is there a reason you are using a CIN? I would strongly suggest that you compile your C code into a normal DLL and then call it using the Call library nodes, especially because you sound like you have some experience in Visual Studio.

CINs are an older technology and as you are discovering using the CINs is much more difficult. We can all try to help you get the CIN to work, however if you are simple calling a DLL you will discover we all have a lot more experience and can be of more help. In addition moving DLLs around is far easier than the CINs and the LSBs.

So is there something about the code that necessitates a CIN, or can you compile it into a DLL?
0 Kudos
Message 2 of 4
(2,977 Views)
Well I am trying to control a camera that is connected to the computer. It comes with software but we need LabVIEW (controlling other measurements) to control the camera itself. The camera software came with an SDK and requires a class structure (CCameraControl) class to do this. I attempted to use the Call library function node however the way the camera works is you create a class of this type, connect, and initialize it, then you set up the parameters you need to change from defaults (for example shutter speed, frame rate, etc.) and then you begin recording and save the images. However, all of this requires that you keep the control object you've created, it is what controls the camera. From what I understand, LabVIEW does not support class structure thus I could not call individual functions from the camera's DLL files to control the camera (tried to use clusters but it got messy, the Camera control class has 600 parameters). The code is actually quite simple with the SDK, but after failing with the DLL I decided to attempt to use a CIN. Perhaps I am looking at the problem in the wrong way, but I'd like to see if I could get it working with the CIN. By the way, this is actually the first project I've worked either with Visual C++ or LabVIEW, so while I've been studying vigorously on it I still do not know much. Thank you for you help and very fast response.
0 Kudos
Message 3 of 4
(2,973 Views)


@abriggs8 wrote:
Well I am trying to control a camera that is connected to the computer. It comes with software but we need LabVIEW (controlling other measurements) to control the camera itself. The camera software came with an SDK and requires a class structure (CCameraControl) class to do this. I attempted to use the Call library function node however the way the camera works is you create a class of this type, connect, and initialize it, then you set up the parameters you need to change from defaults (for example shutter speed, frame rate, etc.) and then you begin recording and save the images. However, all of this requires that you keep the control object you've created, it is what controls the camera. From what I understand, LabVIEW does not support class structure thus I could not call individual functions from the camera's DLL files to control the camera (tried to use clusters but it got messy, the Camera control class has 600 parameters). The code is actually quite simple with the SDK, but after failing with the DLL I decided to attempt to use a CIN. Perhaps I am looking at the problem in the wrong way, but I'd like to see if I could get it working with the CIN. By the way, this is actually the first project I've worked either with Visual C++ or LabVIEW, so while I've been studying vigorously on it I still do not know much. Thank you for you help and very fast response.




There is really nothing CINs will be able to help you here which you couldn't solve with a DLL. And a DLL is a lot easier in many aspects as it can export any number of API calls where as if you want to separate your interface into more than one CIN you end up with multiple C code fragments you need to maintain, compile and load into the according VI time after time again. Or you end up with a single CIN with zillion parameters and a function selector to give you access to the different functions this CIN implements.

What you want to do is creating a thin wrapper around your C++ interface, where you treat the object pointer itself as an extra pointer to be passed to the wrapper function.

Something like this for an idea of what I mean:


/* Declare the functions in a header file to be standard C so that C++ does not decorate them */
#if __cplusplus
extern { "C"
#endif

int MyObject_Create(MyObject ** object);
int MyObject_DoSomething1(MyObject *object, int param1, int param2);
int MyObject_DoSomethingElse(MyObject *object, int param1, int param2);
int MyObject_Destroy(MyObject * object);

#if __cplusplus
}
#endif

Your implementation will then look something like this:


#include <.....>
#include "myobject.h"
#include "myobject1.h" /* Above declarations */

int MyObject_Create(MyObject ** object)
{
*object = new MyObject;

if (!*object)
return memFullError;
return noError;
}

int MyObject_DoSomething1(MyObject *object, int param1, int param2)
{
if (!*object)
return ArgumentError;
return object->DoSomething1(param1, param2);
}

int MyObject_DoSomethingElse(MyObject *object, int param1, int param2)
{
if (!*object)
return ArgumentError;
return object->DoSomethingElse(param1, param2);
}

int MyObject_Destroy(MyObject * object)
{
if (!*object)
return ArgumentError;
delete object;
return noError;
}


Of course you can create more complex wrapper functions combining together several object methods if that seems to make sense for an application like LabVIEW to call them always in the same order.

Configure in the Call Library Nodes the pointer for the first function to be an uInt32 passed as pointer and for all other functions just as an uInt32 passed by value.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 4
(2,951 Views)