Browse Source

解决了一旦触发异常无法恢复问题,修改策略为1s发一次正常错误码。同时检测次数可以调小

paint_robot_new-v1.5
Lizongdi 2 weeks ago
parent
commit
e12384f6c7
  1. 4
      RBcore/client_setting.c
  2. 10
      RBcore/daemon_task.c

4
RBcore/client_setting.c

@ -83,6 +83,8 @@ void decode_PV(const char *_pBuffer, uint32_t _iSize)
if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp) if(decoded_PV_variable.TimeStamp>decoded_PV.TimeStamp)
{ {
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; decoded_PV=decoded_PV_variable;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_PV, (void *)&decoded_PV, sizeof(decoded_PV)); 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 + 2] = (crc>>8) &0xff;
g_IV_buffer[IV_o_stream.bytes_written + 3] = crc & 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); rd_ComSend(g_ptlpuart, g_IV_buffer, IV_o_stream.bytes_written + 4);
} }
break; break;

10
RBcore/daemon_task.c

@ -19,12 +19,13 @@
#include "BHBF.h" #include "BHBF.h"
#include "msg_center.h" #include "msg_center.h"
#include "bsp_Error.pb.h" #include "bsp_Error.pb.h"
#include "rd_time.h"
/*----------------------------------------------* /*----------------------------------------------*
* 常量/宏定义(前置,供模块级变量与函数使用) * * 常量/宏定义(前置,供模块级变量与函数使用) *
*----------------------------------------------*/ *----------------------------------------------*/
#define COM_ERROR_MODULE_NUM 7 // ComError 模块数量(位 0~6) #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) void daemon_PollComError(void)
{ {
static uint32_t uiLastSendTick = 0;
for (int32_t i = 0; i < COM_ERROR_MODULE_NUM; i++) for (int32_t i = 0; i < COM_ERROR_MODULE_NUM; i++)
{ {
if (Get_BIT(&g_iCom_Error_Code, i) == 1) 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); SET_BIT_0(&g_iCom_Error_Code, i);
g_auiComErrorCount[i] = 0; // 失联计数清零 g_auiComErrorCount[i] = 0; // 失联计数清零
SET_BIT_0(&g_iCom_Error_Status, i); // 标记模块正常 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 else
{ {

Loading…
Cancel
Save