From 52ce9893a71311c46d4e9ba14ef2a98b3b715e36 Mon Sep 17 00:00:00 2001 From: fujuntang <fujuntang@smartai.com> Date: 星期日, 26 九月 2021 21:57:24 +0800 Subject: [PATCH] trival version: need confirm whether protobuf can run weil yet. --- src/bh_api.cpp | 20 ++++++++++++-------- 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bh_api.cpp b/src/bh_api.cpp index 312b203..f4215d3 100644 --- a/src/bh_api.cpp +++ b/src/bh_api.cpp @@ -7,9 +7,7 @@ #include "bh_api.h" #include <pthread.h> #include <getopt.h> -#include "bhome_msg_api.pb.h" -#include "bhome_msg.pb.h" -#include "error_msg.pb.h" +#include "../proto/source/error_msg.pb.h" #include "../proto/source/bhome_msg.pb.h" #include "../proto/source/bhome_msg_api.pb.h" @@ -530,9 +528,10 @@ if (mtr_list_num > sizeof(mtr_list) / sizeof(mtr_list[0])) { mtr_list_num = sizeof(mtr_list) / sizeof(mtr_list[0]); } - + + Proc_ptr = &(ptr->procData); for(int i = 0; i < mtr_list_num; i++) { - mtr_list[i].proc_id = ptr->procData.proc_id; + mtr_list[i].proc_id = (Proc_ptr + i)->proc_id; mtr_list[i].mq_id = ID_RSV; mtr_list[i].abs_addr = ABS_ID_RSV; mtr_list[i].ip = "127.0.0.1"; @@ -1162,6 +1161,7 @@ int sec, nsec; std::string MsgID; int timeout_ms = 3000; + char data_buf[MAX_STR_LEN] = { 0x00 }; char buf_temp[MAX_STR_LEN] = { 0x00 }; char *topics_buf = NULL; @@ -1225,7 +1225,9 @@ rv = net_mod_socket_reg(gNetmod_socket, buf_temp, strlen(buf_temp), &buf, &size, timeout_ms, PROC_QUE_STCS); if (rv == 0) { - val = atoi((char *)buf); + len = size > (sizeof(data_buf) - 1) ? (sizeof(data_buf) - 1) : size; + memcpy(data_buf, (char *)buf, len); + val = atoi((char *)data_buf); free(buf); @@ -1316,6 +1318,7 @@ net_node_t node; int node_size; int recv_arr_size; + char data_buf[MAX_STR_LEN] = { 0x00 }; net_mod_recv_msg_t *recv_arr; net_mod_err_t *errarr; int errarr_size = 0; @@ -1389,7 +1392,9 @@ rv = net_mod_socket_reg(gNetmod_socket, buf_temp, strlen(buf_temp), &buf, &size, timeout_ms, PROC_QUE_STCS); if (rv == 0) { - val = atoi((char *)buf); + len = size > (sizeof(data_buf) - 1) ? (sizeof(data_buf) - 1) : size; + memcpy(data_buf, (char *)buf, len); + val = atoi((char *)data_buf); free(buf); @@ -1401,7 +1406,6 @@ len += strlen(_input1.data); #endif - data = net_mod_socket_svr_get(gNetmod_socket); topics_buf = (char *)malloc(len); if (topics_buf == NULL) { -- Gitblit v1.8.0