LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dll pointer memory allocation

Solved!
Go to solution

Hi,

 

I am very new to LabVIEW and I have been struggling with this third party provided dll for a quite long time. I am able to configure the device (though with error code showing insufficient resource), get number of sensors connected, and the sensor ID. But I can't receive any data from the device and I am thinking it might be memory allocation problem. 

 

I am using LabVIEW 2015 32bit on Windows 10. 

This is the documentation provided by the vendor, and the apdm_ctx_t seems to be a void pointer based on the API (typedef void apdm_ctx_t)

APDM_EXPORT apdm_ctx_t apdm_ctx_allocate_new_context (void )
             Allocates memory a handle to be used by the apdm libraries.
             Returns
Non-zero on success, zero otherwise

Based on some previous post, I configure the return of the above function to be signed pointer size integer. And the following functions will receive this context as numeric and pass by value.

 

In the attached png, the apdm_get_next_record requires a complicated struct. I make it as a cluster and feed into the function node (see fig). 

The sequence of the vi follows the Matlab code provided by the vendor. I have no idea why the vi keeps returning error code: no data received....

 

Any thoughts would be great and I can provide more info if needed. Thanks!

 

 

Download All
0 Kudos
Message 1 of 10
(3,956 Views)

While LabVIEW is indeed a graphical programming language, a picture of the diagram only can tell us so much. With the Call Library Node most of the really interesting things are in the Configuration Dialog not in the LabVIEW diagram. That part is totally lost in a diagram screenshot.

 

So please provide the header file for your DLL where the functions and the relevant types like apdm_ctx_t and apdm_record_t are declared and also a copy of the actual VIs containing the Call Library Nodes. If you do a Save for Previous... version of these VIs you increase the chance of more people being able to look at it, as quite a few LabVIEW users don't always are sitting on a computer with the latest version installed.

 

What you expect us in your original post to do is similar to sending a picture of a car to a mechanicien and asking him why it doesn't drive anymore.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 10
(3,915 Views)

Thanks for pointing it out and sorry for the confusion!

 

I have attached the zipfolder which includes .h file, .dll, API documentation, Matlab code used for reference, and my autoconfiguration and data streaming vi. Let me know if you need anything else.

 

 

0 Kudos
Message 3 of 10
(3,888 Views)

Three comments:

 

1) The archive misses the file: autoconfigure device and accesspoint4.vi , which seems to be where you have trouble

2) The include file apdm_stdincludes.h is referenced but missing. It most likely contains the definition of APDM_EXPORT

3) In ctx_disconnect() you mixed the definition of the datatypes. The return value should be an int32 and the context parameter should be pointer sized

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 10
(3,881 Views)

Hi Rolf,

 

Thanks for the reply. I have attached the autoconfigure device and accesspoint4.vi and apdm_stdincludes.h. I don't think it includes the APDM_EXPORT. And I fix the ctx_disconnect.

 

I am able to configure the device, but not able to acquire any data from the device.

 

0 Kudos
Message 5 of 10
(3,873 Views)
Solution
Accepted by topic author maggie4_apple

Looking briefly through the code provided I don't see glaring mistakes. Are you really sure that you don't misinterprete any return values as failuree or maybe something in your actual system setup is preventing you to get the values you are expecting?

 

You haven't really explained what you think you should get and what you get instead. Also the matlab example only shows the use of apdm_ctx_autoconfigure_devices_and_accesspoint5() while you use apdm_ctx_autoconfigure_devices_and_accesspoint4() which I suppose is not a big problem as the Matlab example simply passes an extra 0 parameter to the function. However that example does not at all show how you are supposed to call apdm_ctx_get_next_record() and then calls at the end also apdm_exit() which you do nowhere.

 

For now it seems more a problem about using the functions of your DLL in the correct way and order than something that would need to be fixed in the Call Library Nodes to access your DLL. One suggestion to improve the VIs you have now would be to actually do proper error handling. for now those functions do nothing with the return value of functions. The proper way would be to check the documentation and if a function return value or return parameter can indicate an error to actually cause the error cluster to propagate a meaningful error code downstreams. And all the functions except the ones which are meant to dispose any resources should have a case structure that on incoming error does nothing and simply passes the error through.

 

But don't blindly assume that since function 1 return non 0 for an error that all the other functions do so too. Some might actually return the number of found resources or whatever with 0 indicating no resources or an error. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 10
(3,828 Views)

Hi Rolf, 

 

Thank you for your reply! You are correct. There's nothing wrong with the call function node. The bug is that LabVIEW cannot automatically create the path for temp fifo file so I will have to specify a path. And then problem solved...

It's very important to read the debug log file haha. 

 

Again, thank you! Without your posts about .dll, struct, and call function node, I wouldn't even know how to start my project. I will work on my error cluster. 

 

0 Kudos
Message 7 of 10
(3,797 Views)

Hi 

Our school bought the APDM system recently and would like to use their apdm.dll to retrieve their IMU sensor signal. However, I read and refer to your vi, and try to write our own program, we still can't see any data come in. We have seen your uploaded vi in 2016.3, and it seems not the correct version for retrieving the data. Would you please provide the vi sample for us (just let us see the IMU signal in real-time at Windows)? The attached are the LV project that we do. Would somebody have any suggestion?

Best

0 Kudos
Message 8 of 10
(2,642 Views)

It has been a long time.... May I ask which school you are from? I can probably dig up the vi and send it to you. 

0 Kudos
Message 9 of 10
(2,633 Views)

Hi

We are National Yang-Ming University, Taipei, Taiwan. (www.ym.edu.tw)

My e-mail: lai_ot@yahoo.com.tw

Thank you a lot.

0 Kudos
Message 10 of 10
(2,629 Views)