![]() ** Parameter meaning : 1、mb Handle to mailbox object, Which mail control block to get mail from 2、value Email content, You need to save. When receiving mail, In addition to specifying the mailbox handle to receive mail, And specify the storage location of the received mail ( You need a variable to hold the received data ). Wait to send mail : /** Parameters : 1、mb Handle to mailbox object 2、value Email content 3、timeout Timeout time return : RT_EOK Send successfully -RT_ETIMEOUT Overtime -RT_ERROR Failure, Returns an error */ rt_err_t rt_mb_send_wait ( rt_mailbox_t mb, rt_ubase_t value, rt_int32_t timeout ) 1.2.4 Receiving mail Sending without waiting is actually sending mail by waiting, The waiting time is 0. The old rule is to use the source code, Explain and read the notes ( It is also easy to use and copy ~ ~!) # ifdef RT_USING_MAILBOX /** * mailbox structure */ struct rt_mailbox However FreeRTOS The task notification belongs to the task itself, Each task has and only has one notification ,Īnd RT-Thread The mailbox of is uniformly managed by the mailbox control block, Create a new mailbox, Can contain multiple messages ( Each 4 Bytes ). RT-Thread It's kind of similar FreeRTOS Task notification for, The same can only pass 4 Byte content. Mailbox features RAM Less space, More efficient. RT-Thread The message in is a thread 、 Interruption of service 、 Timers are an effective means of sending messages to threads ( Interrupts and timers need non blocking mode, Can't wait to send, Can't accept ).Įach email in the mailbox can only hold fixed 4 Byte content (32 The bit kernel can just pass a pointer ). RT-Thread Record ( One 、RT-Thread edition 、RT-Thread Studio development environment And coordination CubeMX Develop quickly ) īen RT-Thread The development environment recorded in the column : The application of message queue in serial communication will be explained in a separate blog post, This article first makes a basic introduction and explanation of basic examples. Basically, all message types in the actual project can use the way of message queue. Ĭompared with the content of the previous article, The learning of thread communication will be relatively complex, Because it involves the transmission of messages, There may be many different situations when messages are used in actual projects, therefore The usage scenarios and methods of mailbox and message queue are the key, Especially message queuing. But semaphores belong to thread synchronization mechanism, Messages cannot be passed between threads, We introduce in this article mailbox 、 Message queue is a mechanism to realize message transmission between threads. Semaphores similar to those described in the previous article 、 Mutex and event set, mailbox 、 The message queue is also RT-Thread IPC Mechanism. 2.4.1 Understand the principle of message queuing.2.4 Example ( Understand the principle of message queue ).2.3 A brief analysis of the principle of message queue.
0 Comments
Leave a Reply. |