11-02-2009 03:45 AM
Hi everybody,
I'm trying to create a DLL. My problem is: I have to receive bit fields and when I try to use the wizard to get the data, I can't. And when i mask the bitfield (in the C++ structure) I can. So the problem is the bitfield. Is there any way that the labview can read it? (As bit field)
Regards
Felipe
11-02-2009 05:36 AM
Hi kito,
how large is the bitfield?
As long as it is representable by an integer datatype you should use an apropriate typed integer and do the masking with boolean functions and numeric constants...
Also LabView prefers dlls with standard C functions (or function definitions), C++ isn't supported AFAIK.
11-02-2009 07:14 AM
Hi GerdW
Just to correct, I use C instead of C++
I've got a lot of bitfields with diferent size (I mean, I use 16-bit and 32-bit word and inside that, I've got 2 bits, 3 bits, 4 bits and so on)
I am trying to find a way to get those data from C and see in the Labview:
For instance:
the C code is going to send me like that:(16-bit)
variable a :3;
variable b :4;
variable c :5;
variable d :1;
variable e :3;
and I have to get like that. I can't change the C code. So I need to find a way that labview can see like that.
I think labview cannot see like that, but if you know any possibilite, please let me know about that.
Regards
Kito
11-02-2009 07:58 AM
11-02-2009 08:20 AM
Hi GerdW
the problem is that the C code sends me as bitfield and when I try to use the wizard or call library function the labview doesn't recognize as a bitfield, and as I told you the C code cannot be changed.
Regards
Felipe
11-02-2009 08:29 AM
11-02-2009 08:34 AM
No, because I receive as bitfield not as 16- or 32-bit word
Regards
Kito
11-02-2009 08:39 AM
Hi kito,
even when the C compiler interprets that 32-bit word as bitfield: it still is a 32-bit word... (replace 32 by 16, when applicable)
So in LabView define the dll-input as U32 and you should get all bits at once! Labview doesn't know of any bitfields, but it knows about U32 (and other) integer datatype...
11-02-2009 08:48 AM
That is the problem. The C code doesn't sends me like that (16 or 32 bits word)
See how the code is sent:
typedef struct
{
#ifdef L_ENDIAN
unsigned int currentState : 4;
unsigned int bitType : 3;
unsigned int powerMode : 1;
unsigned int transitionID : 16;
unsigned int Spare : 8;
#else
unsigned int Spare : 8;
unsigned int transitionID : 16;
unsigned int powerMode : 1;
unsigned int bitType : 3;
unsigned int currentState : 4;
#endif
}MCP_Tel_MIS_StateMachineOutput;
So I have to get tha data like above showed.
Regards
Kito
11-02-2009 08:53 AM
Hi kito,
with my limited C knowledge I recognize a struct definition consisting of 5 UINTs.
In Labview this is resembled by a cluster of 5 unsigned integers, you just have to check the word length (I suppose it's 16bit, so use U16).