在open62541中从客户端单个请求中读取多个节点

时间:2017-12-01 10:26:38

标签: c client client-server open62541

在open62541中,任何人都可以告诉我对服务器的单个请求中多节点读取的语法。

我一直在做一个读取请求 从open62541客户端到服务器的this

1 个答案:

答案 0 :(得分:2)

您可以使用标准阅读服务:

UA_Client_Service_read(UA_Client *client, const UA_ReadRequest request)

请参阅:https://github.com/open62541/open62541/blob/6c82b082c8a6c3b1faebc43387a1b0cb3eced051/include/ua_client.h#L203

E.g:

UA_ReadRequest request;
UA_ReadRequest_init(&request);
UA_ReadValueId ids[2];
UA_ReadValueId_init(&ids[0]);
ids[0].attributeId = UA_ATTRIBUTEID_VALUE;
ids[0].nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_NAMESPACEARRAY);

UA_ReadValueId_init(&ids[1]);
ids[1].attributeId = UA_ATTRIBUTEID_VALUE;
ids[1].nodeId = UA_NODEID_NUMERIC(0, UA_NS0ID_SERVER_STATUS);

// set here the nodes you want to read
request.nodesToRead = ids;
request.nodesToReadSize = 2;

UA_ReadResponse response = UA_Client_Service_read(client, request);

// do something with the response

Crosspost:https://github.com/open62541/open62541/issues/1426