From ed7f4012da2a4c16ad447d2105e2e0f1c286408b Mon Sep 17 00:00:00 2001 From: Ximeng Li Date: Fri, 3 Apr 2026 16:22:07 +0800 Subject: [PATCH] changed if condition in _MsgQueueRecv and calculation of target position in _MsgQueueUrgentSend --- Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c index 8f9fc191e..3f581619e 100644 --- a/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c +++ b/Ubiquitous/XiZi_IIoT_Macro/kernel/thread/msgqueue.c @@ -180,7 +180,7 @@ static x_err_t _MsgQueueUrgentSend(struct MsgQueue *mq, const void *buffer, x_si if (mq->index < 0) mq->index += mq->max_msgs; - msg = mq->msg_buf + ( ( mq->index + mq->num_msgs ) % mq->max_msgs ) * mq->each_len ; + msg = mq->msg_buf + (mq->index % mq->max_msgs) * mq->each_len; memcpy(msg , buffer, size); mq->num_msgs ++; if (!IsDoubleLinkListEmpty(&mq->send_pend_list)) { @@ -214,7 +214,7 @@ static x_err_t _MsgQueueRecv(struct MsgQueue* mq, timeout = CalculateTickFromTimeMs(msec); lock = CriticalAreaLock(); - if (mq->index == 0 && timeout == 0) { + if (timeout == 0 && mq->num_msgs <= 0) { CriticalAreaUnLock(lock); return -ETIMEOUT; } -- 2.34.1