fail to write indexed value to multi-dimension array

13 views
Skip to first unread message

pinkie cao

unread,
Jun 20, 2022, 8:58:07 AMJun 20
to open62541
hi ,
I use open62541 as ua client.It's good to read/write to one dimension array with specified indexrange. As to multi-dimensions array. reading one element with specified index range  is ok , but write is failed. I want to write one element instead of complete array to multi-dimension array .  My test code is the following:
 UA_WriteRequest wReq;
 UA_WriteRequest_init(&wReq);
 QString strAddr,strindexRange;
 wReq.nodesToWrite = new UA_WriteValue[1];// write one element of multi-dimension array
wReq.nodesToWriteSize =1;

strindexRange = "2,3";// definition of array is arrVar[13,4], write element "2,3"
UA_NodeId writeArrIndexTag = UA_NODEID_STRING_ALLOC(m_namesapce, "arrVar");//node id
wReq.nodesToWrite[0].indexRange = UA_String_fromChars(strindexRange.toUtf8());
wReq.nodesToWrite[0].nodeId = writeArrIndexTag;
wReq.nodesToWrite[0].attributeId = UA_ATTRIBUTEID_VALUE;
wReq.nodesToWrite[0].value.hasValue = true;
wReq.nodesToWrite[0].value.value.storageType = UA_VARIANT_DATA;

//value
UA_Int16 data = 100;
UA_Variant_setArray(&wReq.nodesToWrite[0].value.value, &data, 1, &UA_TYPES[UA_TYPES_INT16]);

//write service
UA_WriteResponse wResp = UA_Client_Service_write(client, wReq);

Please help me if having another way to write one element of multi-dimension array. Appreciate it.  Thanks a lot. Wish your reply.

Julius Pfrommer

unread,
Jun 20, 2022, 9:28:10 AMJun 20
to pinkie cao, open62541
What is the error code returned?
Try if it helps setting [1,1] arrayDimensions in the value.
So you are writing a matrix into a matrix-like index range.

See this unit test for an example that writes a scalar to an index range.

--
You received this message because you are subscribed to the Google Groups "open62541" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open62541+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/open62541/97d36624-8e5c-4452-9cf9-2b500fdad099n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages