Paparazzi UAS  v5.15_devel-164-g81d4ceb
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
unsigned short uint16_t
Definition: types.h:16
MsgQueueStatus
Definition: msg_queue.h:38
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
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
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
int32_t msgqueue_pop(MsgQueue *que, void **msgPtr)
wait then receive message
Definition: msg_queue.c:134
int32_t msgqueue_pop_timeout(MsgQueue *que, void **msgPtr, const systime_t timout)
receive message specifying timeout
Definition: msg_queue.c:139
Dynamic memory allocation based on TLSF library.
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
tlsf_memory_heap_t * heap
Definition: msg_queue.h:227
bool msgqueue_is_empty(MsgQueue *que)
test if queue is empty
Definition: msg_queue.c:59
signed long int32_t
Definition: types.h:19
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
bool msgqueue_is_full(MsgQueue *que)
test if queue is full
Definition: msg_queue.c:50
mailbox_t mb
Definition: msg_queue.h:226
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
MsgQueueUrgency
Definition: msg_queue.h:47
const char * msgqueue_strerror(const MsgQueueStatus errno)
debug api
Definition: msg_queue.c:168