Merge pull request #398 from fengzeroz/main

fix write tag crash
This commit is contained in:
fengzeroz
2022-04-02 16:45:59 +08:00
committed by GitHub
3 changed files with 18 additions and 3 deletions
+4
View File
@@ -336,6 +336,10 @@ int command_rw_write_request(neu_plugin_t *plugin, neu_json_mqtt_t *mqtt,
neu_datatag_t * tag =
neu_datatag_tbl_get_by_name(table, write_req->tag_name);
if (tag == NULL) {
return -1;
}
neu_datatag_id_t id = tag->id;
switch (tag->type) {
+8 -2
View File
@@ -198,8 +198,14 @@ void handle_write(nng_aio *aio)
neu_datatag_table_t *table =
neu_system_get_datatags_table(plugin, node_id);
neu_data_val_t *data = neu_parse_write_req_to_val(req, table);
uint32_t event_id = neu_plugin_get_event_id(plugin);
neu_data_val_t *data = neu_parse_write_req_to_val(req, table);
if (data == NULL) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_TAG_NOT_EXIST, {
http_response(aio, NEU_ERR_TAG_NOT_EXIST, result_error);
})
return;
}
uint32_t event_id = neu_plugin_get_event_id(plugin);
write_add_ctx(event_id, aio);
neu_plugin_send_write_cmd(plugin, event_id, node_id, config, data);
})
+6 -1
View File
@@ -178,12 +178,17 @@ int neu_parse_param(char *buf, char **err_param, int n, neu_json_elem_t *ele,
neu_data_val_t *neu_parse_write_req_to_val(neu_json_write_req_t *req,
neu_datatag_table_t * tbl)
{
neu_datatag_t *tag = neu_datatag_tbl_get_by_name(tbl, req->tag_name);
if (tag == NULL) {
return NULL;
}
neu_data_val_t * val = neu_dvalue_unit_new();
neu_fixed_array_t *array = neu_fixed_array_new(1, sizeof(neu_int_val_t));
neu_int_val_t iv;
neu_data_val_t *v;
neu_datatag_t * tag = neu_datatag_tbl_get_by_name(tbl, req->tag_name);
switch (tag->type) {
case NEU_DTYPE_UINT8: