LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Write an array of string in OPC Server

Hello,

 

I need help, because I try to write 2 string in an array of string in opc server, but just the first string is writing in the array.

The function to write the array of string (like the example of LabWindows/CVI about the function DS_SetDataValue) is:

 

void start_batch(char sqlname[12])
{
char *nomlot[] = {"String Value 1", "String Value 2"};
HRESULT hr = S_OK;

hr = DS_SetDataValue (dsHandle[0][37], CAVT_ARRAY | CAVT_CSTRING, nomlot, sizeof (nomlot) / sizeof (nomlot[0]), 0);
}

 

The array is empty before to launch the application:

image01.JPG

 

And the array becomes as below in the OPC client:

image02.JPG

 

The second string isn't written correctly.

Someone help me please?

 

Thank you.

 

Best Regards.

0 Kudos
Message 1 of 3
(3,615 Views)

Hi Kalcutt,

 

I think you inverted the parameter. Try this way:

 

hr = DS_SetDataValue (dsHandle[0][37], CAVT_CSTRING | CAVT_ARRAY, nomlot, sizeof (nomlot) / sizeof (nomlot[0]), 0);

 

Regards

Romain DUVAL || RF & Semiconductor Staff System Engineer || CLA || CTA
National Instruments France

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

Hello,

 

Thank you for your advice, but it doesn't work even like it.

And I have seen in the past, that the help about DataSocket is wrong, because for all communication I can't use CAVT_CSTRING | CAVT_ARRAY but I have to use CAVT_ARRAYCAVT_CSTRING otherwise it doesn't work.

 

In the help, the explanations are :

 

Example

Example of scalar of type double
double value = 5.5;
DS_SetDataValue (dsHandle, CAVT_DOUBLE, &value, 0, 0);


Example of string
char *value = "String Value";
DS_SetDataValue (dsHandle, CAVT_CSTRING, value, 0, 0);
Example of 1D array of doubles

double value[] = {4.0, 5.0, 5.5};
DS_SetDataValue (dsHandle, CAVT_DOUBLE | CAVT_ARRAY, value, sizeof (value) / sizeof (value[0]), 0);


Example of 1D array of strings
char *value[] = {"String Value 1", "String Value 2"};
DS_SetDataValue (dsHandle, CAVT_CSTRING | CAVT_ARRAY, value, sizeof (value) / sizeof (value[0]), 0);

 

But it's wrong.

 

Bye.

0 Kudos
Message 3 of 3
(3,588 Views)