From e0db2eaa10a4192f8d015b6ebf7d7a21aece8e54 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Thu, 24 Sep 2026 15:56:05 +0800 Subject: [PATCH] =?UTF-8?q?ringbuffer=E8=BF=99=E9=87=8C=E4=BC=9A=E6=AD=BB?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF=EF=BC=8C=E5=8F=B3=E7=94=B5=E6=9C=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=A0=81=E8=B5=8B=E5=80=BC=E5=89=8D=E4=B9=9F=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/ringbuffer/ringbuffer.c | 17 +++-------------- project/paint_robot_new/paint_robot_new.c | 4 ++-- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/library/ringbuffer/ringbuffer.c b/library/ringbuffer/ringbuffer.c index 40d9d14..46958ee 100644 --- a/library/ringbuffer/ringbuffer.c +++ b/library/ringbuffer/ringbuffer.c @@ -395,7 +395,6 @@ int rd_RingbufferGetchar(rd_ringbuf_t *rb, char *ch) int rd_RingbufferDataLen(rd_ringbuf_t *rb) { if (!rb) return RD_INVALUE; - int iRet = 0; unsigned short wi = ATOMIC_LOAD(&rb->m_sWriteIndex, unsigned short, ATOMIC_ORDER_ACQUIRE); unsigned short ri = ATOMIC_LOAD(&rb->m_sReadIndex, unsigned short, ATOMIC_ORDER_RELAXED); @@ -403,24 +402,14 @@ int rd_RingbufferDataLen(rd_ringbuf_t *rb) unsigned char rb_m = ATOMIC_LOAD(&rb->m_bReadMirror, unsigned char, ATOMIC_ORDER_RELAXED); if (wi == ri) { - iRet = (wb == rb_m) ? 0 : rb->m_iBufsize; + return (wb == rb_m) ? 0 : rb->m_iBufsize; } if (wb == rb_m) { - iRet = wi - ri; + return wi - ri; } else { - iRet = rb->m_iBufsize - (ri - wi); + return rb->m_iBufsize - (ri - wi); } - - if (iRet >= 0) - { - return iRet; - } - else - { - log_e("wb = %d, rb_m = %d, wi = %d, ri = %d", wb, rb_m, wi, ri); - return 0; - } } /** diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index ad75a6a..43e0b6e 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -757,7 +757,7 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) g_stIV.Left_Motor_Err = uiFailtCode[1]; MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_LEFT_MOTOR, NULL, 0); } - else + else if (uiFailtCode[0] == 2) { g_stIV.Right_Motor_Err = uiFailtCode[1]; MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_RIGHT_MOTOR, NULL, 0); @@ -866,11 +866,11 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) log_a("Motor Error ! error code: left [%d] right [%d]", g_stIV.Left_Motor_Err, g_stIV.Right_Motor_Err); } - MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_DISABLE, NULL, 0); MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0); if (g_stMK32.IsOnline == 0) { g_Is_All_Button_Reset = 0; + MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_DISABLE, NULL, 0); } break; }