Игорь
unread,Apr 29, 2022, 3:54:33 AM4/29/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to open62541
Hi, dear community.
I have problem whith getting date about node in callbacks function.
addValueCallbak - the function for adding callbacks on variable nodes.
Here currentNodeId is ns=1;i=Name
static void addValueCallback(UA_Server *server, char* variableNodeName) {
UA_NodeId currentNodeId = UA_NODEID_STRING(1, variableNodeName);
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
"The CALLBACK add on VARIABLE: %s",variableNodeName);
UA_ValueCallback callback;
callback.onRead = beforeRead;
callback.onWrite = afterWrite;
UA_Server_setVariableNode_valueCallback(server, currentNodeId, callback);
}
afterWrite will be called when the client chenges the value of variable.
In this function after call nodeId is ns=864;i=0.
static void afterWrite(UA_Server *server,
const UA_NodeId *sessionId, void *sessionContext,
const UA_NodeId *nodeId, void *nodeContext,
const UA_NumericRange *range, const UA_DataValue *data) {
UA_String out = UA_STRING_NULL;
UA_print(&nodeId, &UA_TYPES[UA_TYPES_NODEID], &out);
printf("%.*s\n", (int)out.length, out.data);
UA_String_clear(&out);
}
Please help me understand: where i do something wrong?
How can i get the right nodeId and new value of varibale in function afterWrite?
br
----
Igor