From 0cf75b9082dd9627fa564217e8f6131a2900f938 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Thu, 24 Sep 2026 14:11:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=94=B5=E6=9C=BA=E4=BC=98=E5=85=88=E7=BA=A7?= =?UTF-8?q?=E8=B0=83=E9=AB=98=EF=BC=9B2.=E5=A2=9E=E5=8A=A0=E7=94=B5?= =?UTF-8?q?=E6=9C=BA=E6=8A=A5=E6=96=87=E5=8F=91=E9=80=81=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E6=97=A5=E5=BF=97=EF=BC=9B3.=E7=94=B5=E6=9C=BA=E6=9C=89?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E6=97=B6=E6=96=AD=E7=94=B5=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E9=87=8D=E7=BD=AE=E6=8C=89=E9=94=AE=E5=A4=8D=E4=BD=8D?= =?UTF-8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RBcore/drv_interface.c | 2 +- library/ringbuffer/ringbuffer.c | 17 ++++++++++++++--- project/paint_robot_new/paint_robot_new.c | 5 ++++- .../paint_robot_new/paint_robot_new_motors.c | 8 ++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/RBcore/drv_interface.c b/RBcore/drv_interface.c index 7cc9a17..c0111dd 100644 --- a/RBcore/drv_interface.c +++ b/RBcore/drv_interface.c @@ -278,7 +278,7 @@ void Drv_InterfaceInit(void) const osThreadAttr_t motor_task_attributes = { .name = MODULE_NAME_MOTOR, .stack_size = THREAD_DEFAULT_STACK, - .priority = (osPriority_t) osPriorityRealtime1, + .priority = (osPriority_t) osPriorityRealtime2, }; (void)osThreadNew(MotorTask, NULL, &motor_task_attributes); diff --git a/library/ringbuffer/ringbuffer.c b/library/ringbuffer/ringbuffer.c index 46958ee..40d9d14 100644 --- a/library/ringbuffer/ringbuffer.c +++ b/library/ringbuffer/ringbuffer.c @@ -395,6 +395,7 @@ 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); @@ -402,14 +403,24 @@ int rd_RingbufferDataLen(rd_ringbuf_t *rb) unsigned char rb_m = ATOMIC_LOAD(&rb->m_bReadMirror, unsigned char, ATOMIC_ORDER_RELAXED); if (wi == ri) { - return (wb == rb_m) ? 0 : rb->m_iBufsize; + iRet = (wb == rb_m) ? 0 : rb->m_iBufsize; } if (wb == rb_m) { - return wi - ri; + iRet = wi - ri; } else { - return rb->m_iBufsize - (ri - wi); + iRet = 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 3d5b9b0..b8d5e02 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -931,7 +931,10 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) MsgCenter_SendTo(MODULE_NAME_MOTOR, MOTOR_POWER_DISABLE, NULL, 0); MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_CMD_STOP_ALL, NULL, 0); - g_Is_All_Button_Reset = 0; + if (g_stMK32.IsOnline == 0) + { + g_Is_All_Button_Reset = 0; + } break; } diff --git a/project/paint_robot_new/paint_robot_new_motors.c b/project/paint_robot_new/paint_robot_new_motors.c index f10176c..b0dc3a9 100644 --- a/project/paint_robot_new/paint_robot_new_motors.c +++ b/project/paint_robot_new/paint_robot_new_motors.c @@ -243,6 +243,7 @@ void MotorTask(void *argument) { static int LS_Motor_Config_Count = 0; static int iStatusQueryCycle = 0; + static int iLastiCount = 0; if (LS_Motor_Config_Count <= 200) { @@ -253,10 +254,17 @@ void MotorTask(void *argument) Rd_Delay(4); } + int iCurrentCount = Rd_GetTime(); + if (iCurrentCount - iLastiCount >= 1000) + { + log_e("Send motor timeout (%d) !", iCurrentCount - iLastiCount); + } + MotorMgr_SetTargetSpeed(g_apstMotors[0], g_aiMotorSpeed[0]); Rd_Delay(4); MotorMgr_SetTargetSpeed(g_apstMotors[1], g_aiMotorSpeed[1]); Rd_Delay(4); + iLastiCount = Rd_GetTime(); if (++iStatusQueryCycle >= 10) {