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.
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.
12-10-2012 05:24 AM
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
12-10-2012 10:29 AM
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.
12-10-2012 10:54 AM - edited 12-10-2012 10:55 AM
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.
12-11-2012 04:14 AM
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