From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cluster array to c structure in DLL

Hi guys,
I have a problem which I am stuck at, so I will appreciate any help.
What I need to do is to pass a cluster array to a Call Library Function as a pointer to a structure array. I have used the adapt to type option and pointer to handles option but nothing works. I tried passing just a single cluster but even that doesn't work.
Can anyone please tell me what I need to do. The dll is provided as part of my instrument driver (Intelligent instrument's dasport PCI-20450P-24) and I am tring to make VI's so the dasports can be used in labview. I imagine I have to make some sort of CIN that converts a whatever labview passes to a C structure array and pass it to the DLL function right? Well, then what sort of code do I write
in the CIN.
I am very new to labview and C, so if you have a bit of time, explain it to me like I am a six year old!
Better yet, has anyone got a similar sort of CIN already which I can use?
Thank you,
Setu.
0 Kudos
Message 1 of 7
(3,752 Views)
Setu,

First, it may be useful to check these articles:

- "An Overview of Accessing DLLs or Shared Libraries from LabVIEW" [http://zone.ni.com/devzone/conceptd.nsf/ webmain/ B26A875ACA51C567862567CA0055FF24?opendoc ument&node=DZ52048_US]


- "Passing a Variety of Data Types from DLL to LabVIEW
" [http://zone.ni.com/devzone/explprog.nsf/ webmain/ 9E21592A5F39238C862569880064D694?opendoc ument&node=DZ52048_US]

- "Calling a DLL from LabVIEW with struct Parameters" [http://zone.ni.com/devzone/explprog.nsf/webmain/F5F5257756C4D0F88625651B005C9A5E?opendocument&node=DZ52048_US]

Second, your problems are probably related to default values of cluster's elements ... you have to take care to have a large enough input to contain the output value (for exampl
e, if one element is a string and the output value of it is 50 characters long, before calling the DLL, set its value with more than 50 chars).
Let us know if you still have problems.


Hope this helps
0 Kudos
Message 2 of 7
(3,752 Views)
Hi,
Thanks for your comment. I read the above documents and I have come up with a plan to create a wrapper function that creates a C structure array from the labview cluster array and return a pointer - Using a CIN. Please look at my comment to Premal Shah here and tell me if you see any flaw in it, or if you think it will work.
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000009D3A0000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=c+structure+dll&USEARCHCONTEXT_QUESTION_S=0

In appreciation,
Setu.
0 Kudos
Message 6 of 7
(3,752 Views)
Setu,

Did you receive this dll in a VI, or just standalone?

If you could post the dll, we might be able to help. Also include the .h file or any documentation that may help us.

Dlls are tough to first learn, but once you get used to them they are pretty easy. I would advise you read the material posted below, and any other applications notes, articles, etc on NIs website. DLLs are tough, especially when you are trying to pass in clusters.

If you have the header file (.h) you can use this information to correctly configure your dll.
0 Kudos
Message 3 of 7
(3,752 Views)
Hi,
The dll came as part of the portlink drivers for the dasport. The link to download it is here:
http://www.instrument.com/pci/download/portlink.zip

The manual for the dasport can be found here:
http://www.instrument.com/pci/manuals/855M393.zip

It is a very long manual but the function I am intested in is pAIConfigureList, the details of which are on page A-8.

I have also attached a VI that I have made for the high speed analog input process for the daspot. The VI is not complete but the necessary initialisation routines are outlined. Some of the VI are for the slow input process and are irrelevant. The main vi is Act1.vi

Thanks for your help.
Regards,
Setu.
0 Kudos
Message 7 of 7
(3,752 Views)
Hello

I was wondering if you found out the solution to your problem as i have the
same problem too...

ANy help shall be appreciated..
Thanks,

"Setu" wrote in message
news:5065000000080000009D3A0000-1011517314000@exchange.ni.com...
> Hi guys,
> I have a problem which I am stuck at, so I will appreciate any help.
> What I need to do is to pass a cluster array to a Call Library
> Function as a pointer to a structure array. I have used the adapt to
> type option and pointer to handles option but nothing works. I tried
> passing just a single cluster but even that doesn't work.
> Can anyone please tell me what I need to do. The dll is provided as
> part of my instrument driver (Intelligent instrument's dasport
> PCI-20450P-24) and I am tring to mak
e VI's so the dasports can be used
> in labview. I imagine I have to make some sort of CIN that converts a
> whatever labview passes to a C structure array and pass it to the DLL
> function right? Well, then what sort of code do I write in the CIN.
> I am very new to labview and C, so if you have a bit of time, explain
> it to me like I am a six year old!
> Better yet, has anyone got a similar sort of CIN already which I can
> use?
> Thank you,
> Setu.
0 Kudos
Message 4 of 7
(3,752 Views)
Hi Premal:

Yes your problem is quite similar to mine. I am new to labview but according to my knowledge this is what needs to be done.
Make a cluster array.
Then create a CIN (Call Interface Node) with two paramaters. One is output only.
Pass the cluster array.
Right Click the CIN and create C file.
Then open visual C++ and modify/add code such that you passed cluster array gets copied into a C structure array which your function needs. Then return a pointer to the newly created structure array.
Have the output of the CIN wired directly to the input of Call library function.

You will need to change the visual C++ compiler environment in order to create the LSB file which you can then load by right clicking the CIN. Instruction on
how to do that are found here:
"Code Interface Reference Manual" http://www.ni.com/pdf/manuals/320539d.pdf

Now since your are dealing with characters as part of your structure, you might choose to pass individual elements to the CIN instead of a cluster array because characters are represented differently in labview and C.

Please note that is only a plan. I have not tired is myself but I am going to soon. So if you forsee any problem or flaw in it please let me know. As I mentioned I am very new to labview (4 weeks to be excat).

Keep me informed if this works or not.
Regards,
Setu.
0 Kudos
Message 5 of 7
(3,752 Views)