diff --git a/RBcore/client_setting.c b/RBcore/client_setting.c index 9c1289a..a6266d2 100644 --- a/RBcore/client_setting.c +++ b/RBcore/client_setting.c @@ -83,7 +83,9 @@ void decode_PV(const char *_pBuffer, uint32_t _iSize) if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp) { - decoded_PV=decoded_PV_variable; + MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_SERIAL, NULL, 0); + MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_UDP, NULL, 0);// udp还没实现这里先防止报错 + decoded_PV=decoded_PV_variable; MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_PV, (void *)&decoded_PV, sizeof(decoded_PV)); } } @@ -126,8 +128,6 @@ static void SendIV_ModuleHandler(const Msg_t *pstMsg) g_IV_buffer[IV_o_stream.bytes_written + 2] = (crc>>8) &0xff; g_IV_buffer[IV_o_stream.bytes_written + 3] = crc & 0xff;; - MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_SERIAL, NULL, 0); - MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_MK32_UDP, NULL, 0);// udp还没实现这里先防止报错 rd_ComSend(g_ptlpuart, g_IV_buffer, IV_o_stream.bytes_written + 4); } break; diff --git a/RBcore/daemon_task.c b/RBcore/daemon_task.c index 54c3136..6e68343 100644 --- a/RBcore/daemon_task.c +++ b/RBcore/daemon_task.c @@ -19,12 +19,13 @@ #include "BHBF.h" #include "msg_center.h" #include "bsp_Error.pb.h" +#include "rd_time.h" /*----------------------------------------------* * 常量/宏定义(前置,供模块级变量与函数使用) * *----------------------------------------------*/ #define COM_ERROR_MODULE_NUM 7 // ComError 模块数量(位 0~6) -#define COM_ERROR_TIMEOUT_THRESHOLD 8000 // 连续 N 次未收到正常信号判定为模块异常 +#define COM_ERROR_TIMEOUT_THRESHOLD 500 // 连续 N 次未收到正常信号判定为模块异常 /*----------------------------------------------* * 外部变量说明 * @@ -84,6 +85,7 @@ int32_t Get_BIT(int32_t* num,int32_t k) *****************************************************************************/ void daemon_PollComError(void) { + static uint32_t uiLastSendTick = 0; for (int32_t i = 0; i < COM_ERROR_MODULE_NUM; i++) { if (Get_BIT(&g_iCom_Error_Code, i) == 1) @@ -92,6 +94,12 @@ void daemon_PollComError(void) SET_BIT_0(&g_iCom_Error_Code, i); g_auiComErrorCount[i] = 0; // 失联计数清零 SET_BIT_0(&g_iCom_Error_Status, i); // 标记模块正常 + uint32_t uiNowTick = Rd_GetTime(); + if ((int32_t)(uiNowTick - uiLastSendTick) >= 1000) + { + uiLastSendTick = uiNowTick; + MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_DAEMON_CODE, &g_iCom_Error_Status, sizeof(int32_t)); + } } else {