Skip to content

兼容rt-thread5.0以上版本,rt_mq_recv返回值的问题#13

Open
zenghaicang wants to merge 1 commit intoRT-Thread-packages:masterfrom
zenghaicang:master
Open

兼容rt-thread5.0以上版本,rt_mq_recv返回值的问题#13
zenghaicang wants to merge 1 commit intoRT-Thread-packages:masterfrom
zenghaicang:master

Conversation

@zenghaicang
Copy link

使用RT_VER_NUM宏,兼容rt-thread5.0以上版本。


result = rt_mq_recv(player->mq, &msg, sizeof(struct play_msg), timeout);
if (result != RT_EOK)
#if RT_VER_NUM > 0x50000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请改成 #if defined(RT_VERSION_CHECK) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 1)) 谢谢

@@ -315,7 +315,11 @@ static int wavplayer_event_handler(struct wavplayer *player, int timeout)
#endif

result = rt_mq_recv(player->mq, &msg, sizeof(struct play_msg), timeout);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result的类型也需要改成rt_ssize_t

@Rbb666
Copy link
Contributor

Rbb666 commented Mar 15, 2025

@zenghaicang 直接按照这个改下吧,已经验证过了:

    rt_ssize_t result;
    struct play_msg msg;
#if (DBG_LEVEL >= DBG_LOG)
    rt_uint8_t last_state;
#endif
    result = rt_mq_recv(player->mq, &msg, sizeof(struct play_msg), timeout);
#if defined(RT_VERSION_CHECK) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 1))
    if (result <= 0)
#else
    if (RT_EOK != result)
#endif
    {
        event = PLAYER_EVENT_NONE;
        return event;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants