fail to write indexed value to multi-dimension array

Skip to first unread message

pinkie cao

Jun 20, 2022, 8:58:07 AM6/20/22
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;
 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;

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

Jun 20, 2022, 9:28:10 AM6/20/22
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
To view this discussion on the web visit
Reply all
Reply to author
0 new messages