LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

locat a buffer

I need to pass pointer(pointing to a buffer) to a function in a dll, the description of the function says "it must be of size "A*B*N*2" and it is of the type unsigned short. But in the demo (in C, and it runs), this buffer is defined as buffer=malloc(A*B*N*sizeof(short)). Are there two equalvalent? What should I pass to the function as I am programming in labview?
Can a computer learn how to program?
0 Kudos
Message 1 of 2
(2,198 Views)
The two sizes you specified for your buffer are most probably equivalent. The sizeof() function in C simply returns the number of bytes of certain datatype, and most PC's today define an unsigned short's size as 2 bytes. To create this buffer in LabVIEW, use the Initialize Array.vi with a numeric of type U16 connected to the "element" input and a value of A*B*N connected to the "dimension size" input. Connect the output of the Initialize Array.vi to the buffer pointer input of the Call Library Function node, and configure that input as follows:

Type: Array
Data Type: Unsigned 16-bit Integer
Dimensions: 1
Array Format: Array Data Pointer

That should successfully pass a pre-allocated buffer from LabVIEW to your DLL!
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 2 of 2
(2,178 Views)