LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

receive bitfield

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

0 Kudos
Message 1 of 21
(3,937 Views)

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.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 21
(3,920 Views)

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

 

0 Kudos
Message 3 of 21
(3,909 Views)

Hi kito,

 

use standard bit arithmetic:

16bits.png

(I hope I got the bit numbers correct Smiley Wink ) The result is available at the IQ-outputs of R&D.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 21
(3,895 Views)

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

0 Kudos
Message 5 of 21
(3,889 Views)

Hi kito,

 

even when I#m not so involved with C coding: you said you have 16- or 32-words containing your bits.

Can't you access those words (as integers) from LabView?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 21
(3,885 Views)

 

No, because I receive as bitfield not as 16- or 32-bit word

 

Regards

 

Kito

0 Kudos
Message 7 of 21
(3,881 Views)

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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 21
(3,877 Views)

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

 

0 Kudos
Message 9 of 21
(3,869 Views)

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).

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 21
(3,857 Views)