LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

returning pointer from dll as a handle

I'm writing a dll that returns a pointer which points at an block of memory which Labview does not need to worry about it. Labview will only need to pass the pointer to my dll. How do I specify the pointer in C++ and Labview? Can I use a varient or an 32bit int? thank you.
0 Kudos
Message 1 of 6
(2,902 Views)
Ahh nvm I figured it out. A 32 unsigned int would work. Can I typecast it something special?
0 Kudos
Message 2 of 6
(2,895 Views)
What do you mean typecast it to something special?  What exactly are you trying to do at this point?
Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 3 of 6
(2,873 Views)

Hello!

 

It seems that I'm having same kind of problem. I have a DLL that reguires passing a HANDLE type interface in calls which are done in a chain. How shoul I do it in LabVIEW using CallLibraryNode? LabVIEW does not need take care of memory management or anything else. Just be able to pass the opened handle as an parameter in a chain.

 

Following is the chain I need to do:

1. Open(HANDLE &interface) //Opens the interface for proceeding functions to use

2. SetParameter(HANDLE &interface, string parameterName, int parameterValue) // Changes the parameter in the interface 

3. Close(HANDLE &interface) //Close the connection to the interface

 

I currently have an state machine where in Initialize state I call the Open function. For the HANDLE parameter I have set the type into Adapt To Type which seems to make it as an unsigned 32 integer. After the call I receive an integer which seems to a valid one. This value is then set into ShiftRegister. However during the next call with same setup for the interface parameter the function call fails as the interface handle is not a valid one. The value I'm receiving from the Shift register still seems to be a valid one.

 

How should the LabVIEW work in this kind of case?

 

--
Kimmo Jokinen
OptoFidelity
0 Kudos
Message 4 of 6
(2,854 Views)

Something special like a handle example would be a queue node pointer built into Labview or a task. They essentially do the samething right. Right now my program is treating the pointer as an unsigned in32, and it's a little confusing. Maybe I'll throw it into a cluster.

 

 cyberias, I did Open(Handle *pointer) and pass it that way using c++. Labview threads *pointer as an unsigned int32

0 Kudos
Message 5 of 6
(2,841 Views)

Hello!

 

Yes I got that one working with the unsigned integer. However I did come a cross  with a new problem. The function tries to return image buffer information in a char* table which should be allocated in LabVIEW not in the dll. The function prototype is as follows:

 

Capture(Handle ifaceHandle, char* buffer, int sizeX, int sizeY)

 

I have tried to allocate memory in the LabVIEW using initialize array and for loop but no success so far. The DLL says that it does not get the allocated memory buffer.

 

How should the allocation be done?

--
Kimmo Jokinen
OptoFidelity
0 Kudos
Message 6 of 6
(2,813 Views)