LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

call DLL with byte** input parameter type

Hi All,


Have anyone knows how to get output parameter from a Call Library Fuction with having the input prameter type is BYTE**. Please see the code below :


void getMsgBuffFromQueue(BYTE**& p_msgBuff)


{


if(m_QueueBuffMsg.GetSize() > 0)


{


p_msgBuff = m_QueueBuffMsgForEqp.DeQueue();


return ;


}


}


I did the test this fuction of the DLL on VC++ 6 with successful. but when I tranfer it to LabView, I cannot get the parameter output data after call this fuction., I donn't know to use which control to get approriate data return.


I define the function call on Labview like that:


void getMsgBuffFromQueueForEqp(Array1DLong **msgBuff);


Is it correct ? If anyone have the solutions, please give me your solution.


Thanks in advance.
0 Kudos
Message 1 of 2
(2,624 Views)
The problem is that Array1DLong is not a C++ array, but a structure definition for a LV array. If you generate the c code from the Call Library Node, you'll notice the structure that contains the array size as part of it. In addition, there are a lot of rules about how memory should be allocated for the array elements - it is all covered in the "Using External Code in LabVIEW" manual.
 
I'll also point out that your definition does not match the code. A BYTE**& is actually a BYTE*** - the C++ concept of a reference is really a pointer under the covers - it is just that the C++ language provides special support for it. However, for anyone calling the method from the outside, it needs to know that it is really a pointer. Also, if I remember correctly, you can't expose a C++ method with a reference in the definition with an extern "C" statement, which is what you probably want to do in order to easily hook it up to LV...otherwise you'll have to deal with the C++ name-mangled version.
 
There are two ways I would recommend going here.
 
1. Don't use a Call Library Node but a CIN instead. The manual will walk you through the work necessary to marshall the two different data types in and out of LV.
 
2. Return the buffer to LV as a void*. In this case what are you saying to LV is "here is a handle I want you to hold onto...just give it back to me when I need it". Then you create some additional C functions that take the void* and do the data manipulation with it.
 
Which one you pick depends a lot of what you want. If you want to manipulate the data within LV with LV constructs, you need to go with #1. If you just need to pass the buffer to another C function, then #2 is the way to go.
 
Did that make any sense?
0 Kudos
Message 2 of 2
(2,604 Views)