LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use network variable to transfer C structure data?

Solved!
Go to solution

I found a CNVStruct in CNVDataType.

When calling "CNVCreateScalarDataValue" I always get a error message "Data type is invalid".

 

typedef struct TestType_t {
  int           float2[2];
  unsigned char Data[16];
} TestType;

 

 TestType    TestData = {{1,2},"23456"};

CNVCreateScalarDataValue(&data, CNVStruct, &TestData);

 

Does Network Variable only support primitive data types??

Can I transfer C structure data?

0 Kudos
Message 1 of 2
(3,484 Views)
Solution
Accepted by topic author VincentY

Hey Vincent - 

 

You can send structure types, but you have to build them up.  Because your structure contains arrays, you have even more building to do.  It would look something like this:

 

CNVData dataStruct;
CNVData dataArrays[2];
int dims[] = {2};
TestType testData = { { 1, 2 }, "23456" };

CNVCreateArrayDataValue (&dataArrays[0], CNVInt32, testData.float2, 1, dims);
dims[0] = 16;
CNVCreateArrayDataValue (&dataArrays[1], CNVUInt8, testData.Data, 1, dims);
CNVCreateStructDataValue (&dataStruct, dataArrays, 2);

 

For more examples, check out the example 3DSimWriter.  Let me know if you have any questions!

 

NickB

National Instruments 

0 Kudos
Message 2 of 2
(3,472 Views)