From 3efd8e17bdff52202edcf192cb792ebbba86503f Mon Sep 17 00:00:00 2001 From: Sathish Kuttan Date: Fri, 9 Nov 2018 21:03:10 -0800 Subject: [PATCH] kernel: Add k_msgq_peek() API Add an API to peek into a message queue and read the first message without removing the message from the queue. Signed-off-by: Sathish Kuttan --- include/kernel.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/kernel.h b/include/kernel.h index f85978420b0..545196bb029 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -3327,6 +3327,23 @@ __syscall int k_msgq_put(struct k_msgq *q, void *data, s32_t timeout); */ __syscall int k_msgq_get(struct k_msgq *q, void *data, s32_t timeout); +/** + * @brief Peek/read a message from a message queue. + * + * This routine reads a message from message queue @a q in a "first in, + * first out" manner and leaves the message in the queue. + * + * @note Can be called by ISRs. + * + * @param q Address of the message queue. + * @param data Address of area to hold the message read from the queue. + * + * @retval 0 Message read. + * @retval -ENOMSG Returned when the queue has no message. + * @req K-MSGQ-002 + */ +__syscall int k_msgq_peek(struct k_msgq *q, void *data); + /** * @brief Purge a message queue. *