From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass null to a structure in C DLL through LABVIEW

In my application I need to call a C DLL from Labview. The C DLL is as follows.

 

extern “C” long WINAPI PassThruStartMsgFilter

(

unsigned long ChannelID,

unsigned long FilterType,

PASSTHRU_MSG *pMaskMsg,

PASSTHRU_MSG *pPatternMsg,

PASSTHRU_MSG *pFlowControlMsg,

unsigned long *pFilterID

)

 

PASSTHRU_MSG structure is defined below.

 

typedef struct {

unsigned long ProtocolID;

unsigned long RxStatus;

unsigned long TxFlags;

unsigned long Timestamp;

unsigned long DataSize;

unsigned long ExtraDataIndex;

unsigned char Data[12];

} PASSTHRU_MSG;

 

For PASSTHRU_MSG structure I have created cluster and passing the value. The code is working fine with the data in the “Data[12]” array.

When the “DATA[12]”  array is empty I need to send NULL parameter instead of the cluster. I tried sending ZERO of type I32 instead of  cluster. But I received return type error (Not labview error) from the DLL.

 

Attached is the code and the C DLL .  

 

I need support in this regard. Anybody kindly let me know how to pass a NULL parameter to a structure in C.

 

 

With regards

Mamatha

Download All
0 Kudos
Message 1 of 4
(2,392 Views)

Your DLL is expecting 12 bytes of data. You need to initialize your array in the cluster with 12 byte sof data. If the string is empty then fill the array with 12 bytes of of 0s (U8 value equal to 0). Your array should be defined as an U8 array. You may run into problems sinmply wiring the into the DLL since arrays and strings include a length value (when flattened to string) which can cause a decode issue on the DLL side.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 4
(2,379 Views)
PASSTHRU_MSG *pMaskMsg

 Might be worth knowing if you would like to pass a null pointer also. If this is the case, you can set the argument type to be a U32 and pass a value of 0 for this parameter.

Anthony F.
Staff Software Engineer
National Instruments
0 Kudos
Message 3 of 4
(2,376 Views)

 I converted cluster to array and passed the value to the DLL. When it is required to send NULL parameter I passed empty array.

This resolved the issue.

 

Thank you.

With Regards

Mamatha.B

0 Kudos
Message 4 of 4
(2,356 Views)