LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Call Library Function Node To Return C++ Structure Information

Hi everyone.  This question is for all you LabVIEW gurus out there.

 

I am trying to call a function from a .dll to get information from a structure about a device (FT232H chip).  I am using the "Call Library Function Node" to do this in LabVIEW.  My issue is I do not know how to set up the "Call LIbrary Function Node" parameter for a C++ structure.  How do I set up the pointer to FT_DEVICE_LIST_INFO_NODE structure using the "Call Library Function Node" so that I can read back the device information?

 

The details of the C++ function and the structure are below.

 

Thanks for everyone's help!

 

 

The C++ function is the following:

 

FT_STATUS I2C_GetChannelInfo (uint32 index, FT_DEVICE_LIST_INFO_NODE *chanInfo)

 

In = index (Index of the channel)

Out = *chanInfo (Pointer to FT_DEVICE_LIST_INFO_NODE structure)

 

The pointer to the FT_DEVICE_LIST_INFO_NODE is defined as:

 

typedef struct _FT_DEVICE_LIST_INFO_NODE {
ULONG Flags;
ULONG Type;
ULONG ID;
DWORD LocId;
char SerialNumber[16];
char Description[64];
FT_HANDLE ftHandle;
} FT_DEVICE_LIST_INFO_NODE;

 

 

0 Kudos
Message 1 of 30
(5,647 Views)

Already asked repeatedly, although for different structs. Please search the forum first, give it a try, and post back with your code attached and details of the error if you cannot get it working. A small sampling of previous discussions:

http://forums.ni.com/t5/LabVIEW/Interface-dll-function-with-struct-in-LabVIEW/td-p/1490848

http://forums.ni.com/t5/LabVIEW/Passing-structure-pointer-to-dll/td-p/888183

http://forums.ni.com/t5/LabVIEW/Call-DLL-function-with-pointer-to-simple-struct/td-p/2682793

Message 2 of 30
(5,637 Views)
There are LabVIEW examples available on the ftdi site. Have you looked at them?
Message 3 of 30
(5,624 Views)

Thanks guys...I have looked at the FTDI website but they don't have any examples that deal with structures.

0 Kudos
Message 4 of 30
(5,614 Views)
You aren't using the d2xx driver?
Message 5 of 30
(5,607 Views)

I was told to use the libMPSSE.dll driver which is a library wrapper around the D2XX driver.

0 Kudos
Message 6 of 30
(5,598 Views)

Dennis,

 

I was told that to talk to I2C devices it would be easier to use the liBMPSSE.dll for I2C.  Is there a way to directly setup the FTDI chip for I2C mode by talking directly to the D2XX.dll driver?

 

Thanks! 

0 Kudos
Message 7 of 30
(5,594 Views)
Told by whom?

I don't know about the details of i2c mode. I used the serial mode. I don't understand why a wrapper around the dll would make things simpler unless you are developing in c++.
Message 8 of 30
(5,589 Views)

Apparently the wrapper library (libMPSSE.dll) does all the controlling of setting up the chip to be able to communicate over I2C.  The liBMPSSE.dll functions make it easier for the user since they don't have to worry about the byte processing.

0 Kudos
Message 9 of 30
(5,580 Views)

Dennis/Nathan,

 

I tried to set up the "Call Library Function Node (CLFN)" correctly in order to read out Device Information from a FTDI Chip (FT232H) but when I run the VI LabVIEW crashes on me always.

 

I have attached the code.  For the FT_DEVICE_LIST_INFO_NODE structure I passed into the "CLFN" a constant cluster of all the structure elements and then I set up the node to:

 

Type: Adapt to Type

Data format: Handles by Value

 

I think LabVIEW crash may have something to do with the fact that the output of the dll function is using a pointer to a structure.  With the Handles by value Data format I am unable to set the Pointer to structure.

 

Can you please take a quick look at the code to see if I am setting the CLFN up correctly?

 

Thanks!

 

 

Once again, here are the C++ Code Details:

 

FT_STATUS I2C_GetChannelInfo (uint32 index, FT_DEVICE_LIST_INFO_NODE *chanInfo)

 

In = index (Index of the channel)

Out = *chanInfo (Pointer to FT_DEVICE_LIST_INFO_NODE structure)

 

The pointer to the FT_DEVICE_LIST_INFO_NODE is defined as:

 

typedef struct _FT_DEVICE_LIST_INFO_NODE {
ULONG Flags;
ULONG Type;
ULONG ID;
DWORD LocId;
char SerialNumber[16];
char Description[64];
FT_HANDLE ftHandle;
} FT_DEVICE_LIST_INFO_NODE;

0 Kudos
Message 10 of 30
(5,554 Views)