Fix OPCUA failed to read data

Because the index is not increased correctly, a single data point reading failure causes all data assignment errors
This commit is contained in:
gc87
2021-11-29 18:02:02 +08:00
committed by Parker Liu
parent 587bf7fefc
commit ec939bd9ed
2 changed files with 9 additions and 3 deletions
+3
View File
@@ -328,10 +328,13 @@ int open62541_client_read(open62541_client_t *client, vector_t *datas)
opcua_data_t *data = (opcua_data_t *) iterator_get(&iter);
if (!read_response.results[count].hasValue) {
data->error = -1;
count++;
continue;
}
if (!UA_Variant_isScalar(&read_response.results[count].value)) {
data->error = -2;
count++;
continue;
}
+6 -3
View File
@@ -86,8 +86,7 @@ static int opcua_plugin_init(neu_plugin_t *plugin)
memset(plugin->handle_context, 0, sizeof(opc_handle_context_t));
plugin->handle_context->plugin = plugin;
plugin->handle_context->table = NULL;
plugin->handle_context->self_node_id = neu_plugin_self_node_id(plugin);
plugin->handle_context->self_node_id = 0;
NEU_LIST_INIT(&plugin->handle_context->subscribe_list,
opc_subscribe_tuple_t, node);
@@ -99,7 +98,7 @@ static int opcua_plugin_init(neu_plugin_t *plugin)
plugin->handle_context->client = NULL;
return -1;
} else {
log_info("Connected to opc.tcp://%s:%d", plugin->option.host,
log_info("Connected to opc.tcp://%s:%s", plugin->option.host,
plugin->option.port);
plugin->handle_context->client = plugin->client;
}
@@ -157,6 +156,10 @@ static int opcua_plugin_request(neu_plugin_t *plugin, neu_request_t *req)
return -2;
}
if (0 == plugin->handle_context->self_node_id) {
plugin->handle_context->self_node_id = neu_plugin_self_node_id(plugin);
}
if (NULL == plugin->handle_context->table) {
plugin->handle_context->table = neu_system_get_datatags_table(
plugin, plugin->handle_context->self_node_id);