Hello,
I'm trying to receive data from a device with a dll. I implemented the manufacturer's dll using the Call Library Function Nodes and got several subvis. I guess the setting is pretty similar to the issue described here: How-to-use-buffer-from-a-3rd-party-dll , but I can't find a solution for my program.
This is my actual program:
![grafik.png grafik.png]()
The sequences work as follows:
1. connect device
2. Add sensor and define buffer: Here I have to provide the device with a buffer into which the data is to be written. This is an array with entries of the type int32. The buffer is divided into equal blocks, whose number and size is also defined. So I have to create a buffer for the data by passing an array of the desired size to the dll function. The buffer is large enough to hold all the data that will be collected during the streaming session.
The C-Syntax for this input is: VLD_addSensor(... int32_t *buffer, ...)
Unfortunately I just can define the size of the array, that has to be filled in the buffer (as shown above), but I can't give in a pointer to the part of the memory, where the array will be filled. When I try to define a pointer and connect this to the entry of my addSensor.vi (I changed the parameters from Array to numeric Pointer to Value in the CLFN) LabView crashes without any error message.
![grafik.png grafik.png]()
3. Initiate Readout and wait 1 second to fil the buffer. The wait.vi in this sequence is necessary to have enough data inside of the buffer.
4. Read buffer: This vi gives out a pointer to the starting address of the array from where I want to read the block size entries.
The C-Syntax is for the Pointer to buffer output is: VLD_readSensor(...int32_t **data,...)
I used MoveBlock to dereference the pointer to a single value, as shown above and described here: Dereferencing-Pointers-from-C-C-DLLs-in-LabVIEW
When I run the vi the output parameter "Data" from MoveBlock is the same value like the pointer "Pointer to Buffer", so I guess MoveBlock doesn't work properly.
I also tried to directly dereference the array with MoveBlock, but then I either get no value for the output of MoveBlock or the error message "Access violation (0xC0000005) bei EIP=0x00007FFB951F85C7" when the input parameter for Size is too big.
5. Drain the buffer, stop readout and disconnect the device. This leads to no problems.
So in conclusion I guess the problem is that I define an array for the buffer in step 2, but no pointer to the location, so there are problems with reading out the buffer in step 4.
Does anyone have a good idea to solve the issue? I attach the vi, the dll and the related header file.