From 33f550cb65c950068ff04c331daeeda3547d2e50 Mon Sep 17 00:00:00 2001 From: zhkag Date: Wed, 21 Jun 2023 10:22:42 +0000 Subject: [Kernel] message 可以返回消息的实际大小 (#7709) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/device/uart/uart.md | 2 +- documentation/thread-comm/thread-comm.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'documentation') diff --git a/documentation/device/uart/uart.md b/documentation/device/uart/uart.md index d49a005019..92ca9b4bf8 100644 --- a/documentation/device/uart/uart.md +++ b/documentation/device/uart/uart.md @@ -575,7 +575,7 @@ static void serial_thread_entry(void *parameter) rt_memset(&msg, 0, sizeof(msg)); /* Read messages from the message queue*/ result = rt_mq_recv(&rx_mq, &msg, sizeof(msg), RT_WAITING_FOREVER); - if (result == RT_EOK) + if (result >= 0) { /*Read data from the serial port*/ rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size); diff --git a/documentation/thread-comm/thread-comm.md b/documentation/thread-comm/thread-comm.md index 4369752855..758c8defa5 100644 --- a/documentation/thread-comm/thread-comm.md +++ b/documentation/thread-comm/thread-comm.md @@ -595,7 +595,7 @@ static void thread1_entry(void *parameter) while (1) { /* Receive messages from the message queue */ - if (rt_mq_recv(&mq, &buf, sizeof(buf), RT_WAITING_FOREVER) == RT_EOK) + if (rt_mq_recv(&mq, &buf, sizeof(buf), RT_WAITING_FOREVER) >= 0) { rt_kprintf("thread1: recv msg from msg queue, the content:%c\n", buf); if (cnt == 19) @@ -784,7 +784,7 @@ void message_handler() struct msg msg_ptr; /* Local variable used to place the message */ /* Receive messages from the message queue into msg_ptr */ - if (rt_mq_recv(mq, (void*)&msg_ptr, sizeof(struct msg)) == RT_EOK) + if (rt_mq_recv(mq, (void*)&msg_ptr, sizeof(struct msg)) >= 0) { /* Successfully received the message, corresponding data processing is performed */ } -- cgit v1.3.1