08-27-2013 08:57 AM
Hello,
I try to call a function using CLFN. My problem is the parameters of the function I try to access.
Here is the function and his parameters:
typedef struct _BAR_INFO
{
ULONG dwSize;
ULONG dwFlag;
}BAR_INFO, PBAR_INFO;
typedef struct _DEVICE_INFO
{
ULONG dwBarNum;
BAR_INFO BarInfo[6];
}DEVICE_INFO, *PDEVICE_INFO;
DLLIMPORT int GetDeviceInfo(
unsigned int devID,
PDEVICE_INFO pdevinfo
)
{
ULONG i;
if(devID >= DevNum)
return PCICORE_DEVICE_NO_FOUND;
if(DevTable[devID].DevHandle == NULL)
return PCICORE_DEVICE_NO_INITIALIZE;
if(pdevinfo == NULL)
return PCICORE_INVALID_PARAMETER;
pdevinfo->dwBarNum = DevTable[devID].DevInfo.dwBarNum;
for(i = 0; i < pdevinfo->dwBarNum; i++)
{
pdevinfo->BarInfo[i].dwFlag =
DevTable[devID].DevInfo.BarInfo[i].dwFlag;
pdevinfo->BarInfo[i].dwSize =
DevTable[devID].DevInfo.BarInfo[i].dwSize;
}
return PCICORE_SUCCESS;
}
In attached file there is the Get Device Info.vi that try to access this function. The code crashes when the function is called.
I probably don't pass the data parameters correctly to the CLFN.
Thanks for your lights §![]()
Solved! Go to Solution.
08-27-2013 08:58 AM
The VI attached
08-27-2013 11:56 AM
A fixed-size array in C is equivalent to a LabVIEW cluster containing the same number of identical elements, so you need to replace the array with a cluster. Also, structs are always passed by reference and the C function expects a pointer to a struct, so you don't need to unbundle. Pass the cluster directly to the function as a single parameter. Try the attached revised version of your VI.
08-28-2013 06:48 AM
Thanks Nathan. Its working fine.