LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuring dll using call library function node

Hi all, 

I am using Labview 2020 sp1 (64 bit)architecture. I have to setup communication and measure values from a 3rd party instrument : Stahl GH 200. Unfortunately they dont have labview vi but they do have a dll file. This dll file contains few functions that I want to use (like one function is for setting up connection, another for getting measured data). But the problem is I am unable to figure out what should I do for function parameters when I am configuring the call library node. There is a header file attached to the dll and so I know the function prototypes. However, as an example, one of the function parameter used in this header file  is "tGH200_Handle hsetupconfiguration". How can i configure this parameter in my call library function node? I am totally lost here.

Any input from you guys will be really helpful. 

0 Kudos
Message 1 of 7
(1,195 Views)

Did you do all of the DLL configuration yourself or did you use the import wizard?  Since you have the .h file I highly recommend you use it to create all the function call VIs.  In the LabVIEW menu, it's under "Tools -> Import ->Shared library (.dll)".

 

Most things that are either a "Handle" or a "pointer" usually end up being 32-bit or 64-bit integers, which are pointers to addresses in memory.  Just treat these as if they are reference wires in LabVIEW, despite being numeric wires on the diagram.  To use them, find a DLL call that creates one, then pass it along to the others that consume it.

Message 2 of 7
(1,167 Views)

Thanks Kyle97330 for your reply. I did the dll configuration by myself. I will try now to do it using import wizard. I have attached the header file with this post. 

I am unable to find out the DLL call which created this handle. Could you please check if there is indeed a dll call which I have missed. 

0 Kudos
Message 3 of 7
(1,142 Views)

The Import Library Wizard is a handy feature to do the repetitive work of generating wrapper VIs for DLL functions. However it can not replace a good programmer who knows what he or she is doing.

The Import Library Wizard is an automatic tool that can take the header file and TRY to create the VI to call a particular function. But the C syntax in the header file is notoriously insufficient to describe all aspects of the function interface. It only (and even that often insufficiently) describes the datatypes of the parameters, their order and pretty much nothing else. Consequently the Import Library Wizard can not invent out of the air new knowledge about how to really properly call that function.

 

Generally said: If you can't create the function calls correctly yourself, the Import Library Wizard will seem to be a solution but it will only give you a false security. It will in most cases create a library that either doesn't work at all due to more or less frequent crashes, or even though it doesn't seem to crash, inevitably will corrupt memory somewhere and cause problems down the road, preferably after you have installed your experimental setup at the North Pole or some other difficult to reach location and the experiment leader calls you up: Get your a** over here ASAP! The application crashes every two days.😀

 

Yes this is dramaticized, but only a little. If you want to be sure that your Call Library Node configuration is correct you CAN use the Import Library Wizard (I usually don't), but you still have to review every single function afterwards very carefully to be correct and usually make at least some modifications. And to do that you need to know everything that you also would need to know in order to create the function yourself in the first place.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 7
(1,130 Views)

Your include file you post includes a GH_200vardef.h file which most likely would describe some of the additional datatypes.

 

As to the tGH200_HANDLE type, yes that is a pointer sized integer as far as the LabVIEW Call Library Node is concerned.

 

However a quick glance at the header file reveals that is uses rather large structs and even unions. It seems not to use pointers inside structs. So yes it will be possible to create Call Library Nodes to call these functions, and the Import Library Wizard will likely be helpful to take part of the work to create this structs in for of LabVIEW clusters but LabVIEW has nothing that can be used to represent C unions. They are only used for flags but still it will be some extra manual work to create the code to deal with these things.

 

There are many potential gotchas in this. First the header seems to use unconditional 1 byte packing for all data structures. That is fine for LabVIEW 32-bit for Windows, since LabVIEW uses also 1 byte packing there, but if you ever plan to go to 64-bit, and that time will arrive that you can only use 64-bit applications, then you are kind of screwed since LabVIEW 64-bit uses standard 8 byte alignment. Of course there is always the chance that this DLL doesn't even exist for 64-bit and never will, which would be just as big of a problem if you are eventually being forced to go to 64-bit.

 

One serious question: How many weeks have you planned to create this driver? And be aware that even after that you will never know if that driver is properly programmed and doesn't cause hidden memory corruptions, if you are not able to fully understand every detail needed to create it from scratch yourself.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 7
(1,128 Views)

Hi rolfk, I have just started working on this project and have one week (max) to implement the driver in my application. Is it possible to work around this problem in a quick time?

0 Kudos
Message 6 of 7
(1,124 Views)

@Kush255 wrote:

Hi rolfk, I have just started working on this project and have one week (max) to implement the driver in my application. Is it possible to work around this problem in a quick time?


Yes, by hiring someone who has real knowledge and experience about this topic. 😀

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(1,120 Views)