10-30-2014 05:17 PM
I have two functions written in C that takes reference to a struct.
Declarations:
IpAddress_Parse(IpAddress* address, const kChar* text)
ConnectIpAddress(connection, const kIpAddress* address)
typedef struct IpAddress
{
int version;
unsigned char address[16];
} IpAddress;
Snippet:
void main(int argc, char **argv)
{
IpAddress ipAddress;
IpAddress_Parse(&ipAddress, "12.0.1.10");
ConnectIpAddress(connection, &ipAddress);
}
I am trying to convert the above to LabVIEW, but have trouble. I have tried to create a Cluster in LV and parse out data from IpAddress_Parse() and pass it back to ConnectIpAddress() as "Adapt to Type" to no avail. Even if I artificially construct a Cluster to pass to ConnectIpAddress() I would have error 1097 from LabView. My cluster included an int and a byte array which follows the typedef struct of IpAddress.
Please provide some pointers as what I am doing wrong. Thanks in advance.
Solved! Go to Solution.
10-30-2014 06:31 PM
Please show your LabVIEW code. The IpAddress cluster should contain a 32-bit integer value, and a nested cluster containing 16 U8 values. You cannot replace a fixed-length C array with a LabVIEW array; you must use a cluster containing the same number of elements instead.
10-31-2014 02:49 PM
Hi nathand,
That was the culprit! Problem solved when I used cluster of elements to present array from C.
Thanks for your help!