mirror of
https://github.com/emqx/neuron.git
synced 2026-10-18 21:50:42 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user