我可以写OPC-UA数组,但是包含'0'元素
例如
我创建TestArray [6]并初始化{1,2,3,4,5,6}
然后我将int v1 [6] = {33,44,55,66,77,88}数组写入。
我检查了UAExpert,将TestArray更改为{33,0,44,0,55,0,66}
为什么包含“ 0”元素?
i我使用了Visual Studio 2017并让客户端打开62541
服务器是PLC设备(B&R PLC)<-几乎是完美的服务器
UA_Int16 TestVal = 0;
printf("========= Write Value =========\n");
//UA_Variant_setArrayCopy
UA_Variant WVel;
UA_Variant_init(&WVel);
int v1[6] = { 33,44,55,66,77,88 };
UA_Variant_setArrayCopy(&WVel, &v1,7, &UA_TYPES[UA_TYPES_INT16]);
UA_WriteValue wValue;
UA_WriteValue_init(&wValue);
wValue.nodeId = UA_NODEID_STRING_ALLOC(6, "Submarine::ballast:states.Array");
wValue.attributeId = UA_ATTRIBUTEID_VALUE;
wValue.value.value = WVel;
wValue.value.hasValue = true;
//wValue.indexRange = UA_STRING("5");
UA_WriteRequest wReq;
UA_WriteRequest_init(&wReq);
wReq.nodesToWrite = &wValue;
wReq.nodesToWriteSize = 1;
UA_WriteResponse wResp = UA_Client_Service_write(client, wReq);
retval = wResp.responseHeader.serviceResult;
UA_WriteResponse_deleteMembers(&wResp);
我无法上传图片,所以我给出了链接