01-22-2010 12:15 PM
Hi everyone,
I'm new to the Labview forums and fairly new to Labview as well.
I'm experiencing some errors in my VI and i can't quite figure out what i'm doing wrong. I have a DLL which was written in VC++. There is a function in the DLL which i am calling out in the VI, but the function contains variables which consist of various multiple data types.
These are my variables in the VC++ code:
typedef struct
{
double dDepth;
double dWidth;
double dHeight;
float fVolume;
float fSurfArea;
int iGood;
int iBad;
} box_t
Then i have my function which calls out these variables:
_declspec(dllexport) int _cdecl ACL_GetData_Array(void *dataArray)
{
arrayStructure->pArray = (array_t *) dataArray;
//PrintGeneral("Array pointer set to retrieve data.\n New address to be displayed.");
//PrintAddr((int)arrayStructure->pArray);
arrayStructure->pArray->dDepth = 30.3;
arrayStructure->pArray->dHeight = 40.4;
arrayStructure->pArray->dWidth = 50.5;
arrayStructure->pArray->fSurfArea = 60.6f;
arrayStructure->pArray->fVolume = 70.7f;
arrayStructure->pArray->iBad = 80;
arrayStructure->pArray->iGood = 90;
return (int) arrayStructure->pArray;
}
Now my question is if I just want to read these variables and display them in Labview, how do i do it? So far, i can get the doubles to display correctly but i haven't had any success with the floats and the ints. If this has been posted by another user, i'm sorry for asking the same question. I've been searching for a few days now and haven't come across any useful information.
Thanks,
George
Solved! Go to Solution.
01-22-2010 01:11 PM - edited 01-22-2010 01:18 PM
You did not include the subVIs, so we can't check how you've set up the CLFN.
I also don't understand what "arrayStructure" is. Is this a static variable? What's box_t for? That function appears to be expecting an array. An array of what? Inside the function it's being typecast to array_t. What's that?
01-22-2010 01:15 PM
Oh right. Sorry. I attached an updated zip file with subvi.
01-22-2010 01:24 PM
Still missing jtTestDLL_init. Please see my edited comment.
Based on this latest update, I don't understand why you're passing in an array of 7 doubles. Can you provide more information as to the datatypes used by the DLL?
Also, your setup of the CLFN does not match the function prototype. The prototype shows only one parameter, but you're passing 2.
01-22-2010 02:02 PM
I'm sorry for the confusion. I spoke to my colleague and he said that this is the code that i should've posted.
*********IN THE HEADER FILE*********
typedef struct
{
double dDepth;
double dWidth;
double dHeight;
float fVolume;
float fSurfArea;
int iGood;
int iBad;
} array_t;
struct ArrayStructure
{
array_t *pArray;
};
*********IN THE CPP FILE***********
array_t *pArrayNew;
_declspec(dllexport) int _cdecl initVariables () {
pArrayNew = new array_t;
arrayStructure = new ArrayStructure;
arrayStructure->pArray = pArrayNew;
arrayStructure->pArray->dDepth = 10.0;
arrayStructure->pArray->dHeight = 20.0;
arrayStructure->pArray->dWidth = 30.0;
return (int) arrayStructure->pArray;
}
_declspec(dllexport) int _cdecl AOS_GetData_Array(void *dataArray) {
arrayStructure->pArray = (array_t *) dataArray;
arrayStructure->pArray->dDepth = 30.3;
arrayStructure->pArray->dHeight = 40.4;
arrayStructure->pArray->dWidth = 50.5;
arrayStructure->pArray->fSurfArea = 60.6f;
arrayStructure->pArray->fVolume = 70.7f;
arrayStructure->pArray->iBad = 80;
arrayStructure->pArray->iGood = 90;
return (int) arrayStructure->pArray;
}
I hope you're able to make more sense with this.
As for your question regarding the 7 doubles, i don't think that is correct. The objective is to extract what has been written in the vc++ code and display it in labview. I figured if the array enters 7 doubles, the first three will be correct since they match up. The next two are floats, and then the last two are ints.
I probably made a mistake with the CLFN as well. Like i said, i'm still new to this stuff and i'm looking for help. Thanks for taking a look.
01-23-2010 11:24 AM
01-23-2010 08:13 PM
01-25-2010 07:37 AM
If possible, can you save the modified VI under version 8.5.1? Labview won't let me open the files that you attached to the forum.
As far as the data structure in the DLL, the programmer had rearranged the data types to go from largest to smallest.
01-25-2010 09:34 AM
ghatz85 wrote:If possible, can you save the modified VI under version 8.5.1? Labview won't let me open the files that you attached to the forum.
Sorry. For some reason I thought the originals were in LV 2009. Attached is 8.5 version.
As far as the data structure in the DLL, the programmer had rearranged the data types to go from largest to smallest.
I was referring to having a structure inside a structure and calling it an "array".
01-26-2010 09:16 AM
Wow. You nailed that one. Thanks so much for the help.
George