ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

struct with pointer

Hello I need to interface with a DLL with the folowing structure:

extern "C" {

struct IDSTRUCT
{
UINT8 code[2];
UINT8 signature[8];
UINT8 revision [4];
};

R2DLL_API BOOL R2DLL_ReadFirmwareHeader (UINT16 port, struct IDSTRUCT* pStoreAdr);

Is there a way to implement this with clusters in labVIEW?

Thanks in advance
0 Kudos
Message 1 of 5
(3,539 Views)
Hi,

the way to go isn't the easiest! Define an U8 array of lets say 50 elements( Contains al necessary bytes + an extra 4), cast it to a string and wire it to the dll terminal(= C String Pointer). The information retrieved is mangled in the string return string. Simply do some byte manipulation ( big/little endian enc.) and you'll have your info.

LabView handles strings like { u32 length, u32* pointer). Refering to above the length long introduces the extra 4!.

Try It

Ruud
0 Kudos
Message 2 of 5
(3,513 Views)
lp1 wrote:

> Hello I need to interface with a DLL with the folowing structure:
>
> extern "C" {
> struct IDSTRUCT {
> UINT8 code[2];<br>
> UINT8 signature[8];
> UINT8 revision [4];
> };
> R2DLL_API BOOL R2DLL_ReadFirmwareHeader (UINT16 port, struct IDSTRUCT* pStoreAdr);
>
> Is there a way to implement this with clusters in labVIEW?

Yep! Create a cluster with an UINT16, and three UINT32. Then you have
all the information. Typecast the UINT16 and the last UIN32 into a
string, and combine the middle two UINT32 into an array, and typecast
them into a string too.

Rolf
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 3 of 5
(3,487 Views)
I'm not sure how to handle structs with unions with another struct inside.  I'm new at LabVIEW
 
what if the structure was like this:
 
#pragma pack(push, 2)
struct IDSTRUCT
{
   UINT32 temp;
   union
   {
      UINT32 x;
      struct
      {
         UINT32 x1    :1;
         UINT32 x2    :31;
      };
   };
  
   union
   {
      UINT32 y;
      struct
      {
         UINT32 y1    :1;
         UINT32 y2    :31;
      };
   };
};
#pragma pack(pop)
0 Kudos
Message 4 of 5
(3,280 Views)

"mudder" <x@no.email> wrote in message news:1171469412642-478205@exchange.ni.com...
I'm not sure how to handle structs with unions with another struct inside.&nbsp; I'm new at LabVIEW
&nbsp;
what if the structure was like this:
&nbsp;
#pragma pack(push, 2)
struct IDSTRUCT{
&nbsp;&nbsp; UINT32 temp;
&nbsp;&nbsp; union
&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UINT32 x;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UINT32 x1&nbsp;&nbsp;&nbsp; :1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UINT32 x2 &nbsp;&nbsp; :31;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };&nbsp;&nbsp; };
&nbsp;&nbsp;
&nbsp;&nbsp; union
&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UINT32 y;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UINT32 y1&nbsp;&nbsp;&nbsp; :1;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UINT32 y2&nbsp;&nbsp;&nbsp; :31;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };&nbsp;&nbsp; };};#pragma pack(pop)




This is basically a pointer to four U32's. Because it is a union, the pointer can point to:


temp { x {x1, x2 } }


Or:


temp { x {y1, y2 } }


I'd use a cluster with 4 U32's. The sub structures have no size, and can be ignored in LabVIEW.


Regards,


Wiebe.


0 Kudos
Message 5 of 5
(3,252 Views)