09-11-2014 11:39 AM
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;
09-11-2014 11:50 AM
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
09-11-2014 01:13 PM
09-11-2014 01:24 PM
Thanks guys...I have looked at the FTDI website but they don't have any examples that deal with structures.
09-11-2014 01:37 PM
09-11-2014 01:49 PM
I was told to use the libMPSSE.dll driver which is a library wrapper around the D2XX driver.
09-11-2014 02:01 PM
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!
09-11-2014 02:08 PM
09-11-2014 02:24 PM
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.
09-11-2014 05:07 PM
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;