Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
msg_queue.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Gautier Hattenberger, Alexandre Bustico
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 /*
23  * @file modules/loggers/sdlog_chibios/msg_queue.h
24  *
25  */
26 #pragma once
27 
28 #include <ch.h>
29 #include <hal.h>
31 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 
38 typedef enum {
46 
48 
49 typedef struct MsgQueue MsgQueue;
50 
51 
62  msg_t *mb_buf, const cnt_t mb_size);
63 
69 bool msgqueue_is_full(MsgQueue *que);
70 
76 bool msgqueue_is_empty(MsgQueue *que);
77 
78 
96 int32_t msgqueue_send(MsgQueue *que, void *msg, const uint16_t msgLen,
97  const MsgQueueUrgency urgency);
98 
99 
117 int32_t msgqueue_send_timeout(MsgQueue *que, void *msg, const uint16_t msgLen,
118  const MsgQueueUrgency urgency, const systime_t timout);
119 
120 
135 int32_t msgqueue_copy_send(MsgQueue *que, const void *msg, const uint16_t msgLen,
136  const MsgQueueUrgency urgency);
137 
138 
153 int32_t msgqueue_copy_send_timeout(MsgQueue *que, const void *msg, const uint16_t msgLen,
154  const MsgQueueUrgency urgency, const systime_t timout);
155 
156 
157 
158 /*
159  * goal : (zero copy api)
160  * get a message to be processed without copy (blocking)
161  *
162  * parameters : INOUT queue object
163  * OUT msg pointer
164  * return value:
165  *
166  */
167 
180 int32_t msgqueue_pop(MsgQueue *que, void **msgPtr);
181 
195 int32_t msgqueue_pop_timeout(MsgQueue *que, void **msgPtr, const systime_t timout);
196 
197 
198 /*
199  goal : (zero copy api)
200  free memory of a precedently given message by PopChunk
201 
202  parameters : INOUT queue object
203  IN ChunkBufferRO pointer
204  */
205 
206 
207 
214 const char *msgqueue_strerror(const MsgQueueStatus errno);
215 
216 /*
217 # _____ _____ _____ __ __ ___ _______ ______
218 # | __ \ | __ \ |_ _| \ \ / / / _ \ |__ __| | ____|
219 # | |__) | | |__) | | | \ \ / / | |_| | | | | |__
220 # | ___/ | _ / | | \ \/ / | _ | | | | __|
221 # | | | | \ \ _| |_ \ / | | | | | | | |____
222 # |_| |_| \_\ |_____| \/ |_| |_| |_| |______|
223 */
224 
225 struct MsgQueue {
226  mailbox_t mb;
228 } ;
229 
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
uint16_t
unsigned short uint16_t
Definition: types.h:16
msgqueue_init
void msgqueue_init(MsgQueue *que, tlsf_memory_heap_t *heap, msg_t *mb_buf, const cnt_t mb_size)
initialise MsgQueue
Definition: msg_queue.c:42
msgqueue_send_timeout
int32_t msgqueue_send_timeout(MsgQueue *que, void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency, const systime_t timout)
send a buffer previously allocated by msgqueue_malloc_before_send
Definition: msg_queue.c:76
tlsf_malloc.h
msgqueue_copy_send_timeout
int32_t msgqueue_copy_send_timeout(MsgQueue *que, const void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency, const systime_t timout)
send a buffer NOT previously allocated
Definition: msg_queue.c:114
_tlsf_memory_heap_t
Definition: tlsf_malloc_arch.c:33
msgqueue_send
int32_t msgqueue_send(MsgQueue *que, void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency)
send a buffer previously allocated by msgqueue_malloc_before_send
Definition: msg_queue.c:69
MsgQueue_OK
@ MsgQueue_OK
Definition: msg_queue.h:44
MsgQueue_MAILBOX_FULL
@ MsgQueue_MAILBOX_FULL
Definition: msg_queue.h:39
MsgQueue::mb
mailbox_t mb
Definition: msg_queue.h:226
msg
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
Definition: high_speed_logger_direct_memory.c:134
MsgQueue_MAILBOX_FAIL
@ MsgQueue_MAILBOX_FAIL
Definition: msg_queue.h:40
MsgQueue_REGULAR
@ MsgQueue_REGULAR
Definition: msg_queue.h:47
MsgQueueUrgency
MsgQueueUrgency
Definition: msg_queue.h:47
msgqueue_is_empty
bool msgqueue_is_empty(MsgQueue *que)
test if queue is empty
Definition: msg_queue.c:59
MsgQueueStatus
MsgQueueStatus
Definition: msg_queue.h:38
msgqueue_pop
int32_t msgqueue_pop(MsgQueue *que, void **msgPtr)
wait then receive message
Definition: msg_queue.c:134
msgqueue_copy_send
int32_t msgqueue_copy_send(MsgQueue *que, const void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency)
send a buffer NOT previously allocated
Definition: msg_queue.c:127
msgqueue_is_full
bool msgqueue_is_full(MsgQueue *que)
test if queue is full
Definition: msg_queue.c:50
MsgQueue_OUT_OF_BAND
@ MsgQueue_OUT_OF_BAND
Definition: msg_queue.h:47
MsgQueue_MAILBOX_NOT_EMPTY
@ MsgQueue_MAILBOX_NOT_EMPTY
Definition: msg_queue.h:42
MsgQueue_INVALID_PTR
@ MsgQueue_INVALID_PTR
Definition: msg_queue.h:43
int32_t
signed long int32_t
Definition: types.h:19
MsgQueue_MAILBOX_TIMEOUT
@ MsgQueue_MAILBOX_TIMEOUT
Definition: msg_queue.h:41
msgqueue_pop_timeout
int32_t msgqueue_pop_timeout(MsgQueue *que, void **msgPtr, const systime_t timout)
receive message specifying timeout
Definition: msg_queue.c:139
MsgQueue::heap
tlsf_memory_heap_t * heap
Definition: msg_queue.h:227
msgqueue_strerror
const char * msgqueue_strerror(const MsgQueueStatus errno)
debug api
Definition: msg_queue.c:168
MsgQueue
Definition: msg_queue.h:225