Paparazzi UAS  v5.15_devel-47-g0391b4d
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
msg_queue.c File Reference
+ Include dependency graph for msg_queue.c:

Go to the source code of this file.

Data Structures

union  MsgPtrLen
 
struct  MsgPtrLen.__unnamed__
 

Macros

#define MSGQ_HEAP   HEAP_CCM
 

Functions

void msgqueue_init (MsgQueue *que, tlsf_memory_heap_t *heap, msg_t *mb_buf, const cnt_t mb_size)
 initialise MsgQueue More...
 
bool msgqueue_is_full (MsgQueue *que)
 test if queue is full More...
 
bool msgqueue_is_empty (MsgQueue *que)
 test if queue is empty More...
 
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 More...
 
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 More...
 
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 More...
 
int32_t msgqueue_copy_send (MsgQueue *que, const void *msg, const uint16_t msgLen, const MsgQueueUrgency urgency)
 send a buffer NOT previously allocated More...
 
int32_t msgqueue_pop (MsgQueue *que, void **msgPtr)
 wait then receive message More...
 
int32_t msgqueue_pop_timeout (MsgQueue *que, void **msgPtr, const systime_t timout)
 receive message specifying timeout More...
 
const char * msgqueue_strerror (const MsgQueueStatus _errno)
 debug api More...
 

Variables

static const char * _strerror []
 

Data Structure Documentation

union MsgPtrLen

Definition at line 33 of file msg_queue.c.

+ Collaboration diagram for MsgPtrLen:
Data Fields
struct MsgPtrLen __unnamed__
msg_t msg_ptr_len
struct MsgPtrLen.__unnamed__

Definition at line 34 of file msg_queue.c.

Data Fields
uint16_t len
uint16_t ptrOfst

Macro Definition Documentation

#define MSGQ_HEAP   HEAP_CCM

Function Documentation

int32_t msgqueue_copy_send ( MsgQueue que,
const void *  msg,
const uint16_t  msgLen,
const MsgQueueUrgency  urgency 
)

send a buffer NOT previously allocated

buffer is copied before beeing sent, buffer is still valid after this function returns. Less effective that zero copy alternatives which has been to be preferably used Non blocking, if queue is full, report error and immediately return

Parameters
[in]quepointer to opaque MsgQueue object
[in]msgpointer to buffer
[in]msgLenlength of buffer (the same param that has been given to msgqueue_malloc_before_send)
[in]urgencyregular=queued at end of fifo or out_of_band queued at start of fifo
Returns
if > 0 : requested length if < 0 : error status (see errors at begining of this header file)

Definition at line 127 of file msg_queue.c.

References msgqueue_copy_send_timeout().

+ Here is the call graph for this function:

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

buffer is copied before beeing sent, buffer is still valid after this function returns. Less effective that zero copy alternatives which has been to be preferably used

Parameters
[in]quepointer to opaque MsgQueue object
[in]msgpointer to buffer
[in]msgLenlength of buffer (the same param that has been given to msgqueue_malloc_before_send)
[in]urgencyregular=queued at end of fifo or out_of_band queued at start of fifo
[in]timout: time to wait for MailBox avaibility (can be TIME_INFINITE or TIME_IMMEDIATE)
Returns
if > 0 : requested length if < 0 : error status (see errors at begining of this header file)

Definition at line 114 of file msg_queue.c.

References MSGQ_HEAP, MsgQueue_MAILBOX_FULL, msgqueue_send_timeout(), and tlsf_malloc_r().

Referenced by msgqueue_copy_send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void msgqueue_init ( MsgQueue que,
tlsf_memory_heap_t heap,
msg_t *  mb_buf,
const cnt_t  mb_size 
)

initialise MsgQueue

init sdQueue objet, tie memory pool buffer, tie mailbox buffer initialize mailbox

Parameters
[out]queopaque object to be initialized
[in]heapreference to the tlsf heap object (needed if module should free memory)
[in]mb_buffinternal buffer used by MailBox (see Chibios Doc)
[in]mb_sizesize of previous buffer (length of MailBox queue)

Definition at line 42 of file msg_queue.c.

References MsgQueue::heap, and MsgQueue::mb.

Referenced by sdLogInit().

+ Here is the caller graph for this function:

bool msgqueue_is_empty ( MsgQueue que)

test if queue is empty

Parameters
[in]quepointer to opaque MsgQueue object
Returns
true if empty, false otherwise

Definition at line 59 of file msg_queue.c.

References MsgQueue::mb.

bool msgqueue_is_full ( MsgQueue que)

test if queue is full

Parameters
[in]quepointer to opaque MsgQueue object
Returns
true if full, false otherwise

Definition at line 50 of file msg_queue.c.

References MsgQueue::mb.

int32_t msgqueue_pop ( MsgQueue que,
void **  msgPtr 
)

wait then receive message

this is zero copy api, blocking call usage : struct MyStruct *msg msgqueue_pop (&que, void (void **) &msg); use msg->myField etc etc tlsf_free(MSGQ_HEAP, msg);

Parameters
[in]quepointer to opaque MsgQueue object
[out]msgPtrpointer to pointer to buffer
Returns
if > 0 : length of received msg if < 0 : error status (see errors at begining of this header file)

Definition at line 134 of file msg_queue.c.

References msgqueue_pop_timeout().

+ Here is the call graph for this function:

int32_t msgqueue_pop_timeout ( MsgQueue que,
void **  msgPtr,
const systime_t  timout 
)

receive message specifying timeout

this is zero copy api, blocking call usage : struct MyStruct *msg msgqueue_pop (&que, void (void **) &msg); use msg->myField etc etc msgqueue_free_after_pop (&que, msg);

Parameters
[in]quepointer to opaque MsgQueue object
[out]msgPtrpointer to pointer to buffer
[in]timout: time to wait for MailBox avaibility (can be TIME_INFINITE or TIME_IMMEDIATE)
Returns
if > 0 : length of received msg if < 0 : error status (see errors at begining of this header file)

Definition at line 139 of file msg_queue.c.

References MsgQueue::mb, MsgPtrLen::msg_ptr_len, MSGQ_HEAP, MsgQueue_MAILBOX_TIMEOUT, status, and tlsf_get_heap_addr().

Referenced by msgqueue_pop().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

deallocation is done by the caching thread which actually write data to sd card from the sender point of view, ptr should be considered invalid after beeing sent. Even if msgqueue_send fail, deallocation is done Non blocking, if queue is full, report error and immediately return usage : msg = tlsf_malloc(MSGQ_HEAP, msg, msgLen); msgqueue_send (que, msg, msgLen, urgency);

Parameters
[in]quepointer to opaque MsgQueue object
[in]msgpointer to buffer given by msgqueue_malloc_before_send
[in]msgLenlength of buffer (the same param that has been given to msgqueue_malloc_before_send)
[in]urgencyregular=queued at end of fifo or out_of_band queued at start of fifo
Returns
if > 0 : requested length if < 0 : error status (see errors at begining of this header file)

Definition at line 69 of file msg_queue.c.

References msgqueue_send_timeout().

+ Here is the call graph for this function:

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

deallocation is done by the caching thread which actually write data to sd card from the sender point of view, ptr should be considered invalid after beeing sent. Even if msgqueue_send fail, deallocation is done usage : msg = tlsf_malloc(MSGQ_HEAP, msg, msgLen); msgqueue_send (que, msg, msgLen, urgency);

Parameters
[in]quepointer to opaque MsgQueue object
[in]msgpointer to buffer given by msgqueue_malloc_before_send
[in]msgLenlength of buffer (the same param that has been given to msgqueue_malloc_before_send)
[in]urgencyregular=queued at end of fifo or out_of_band queued at start of fifo
[in]timout: time to wait for MailBox avaibility (can be TIME_INFINITE or TIME_IMMEDIATE)
Returns
if > 0 : requested length if < 0 : error status (see errors at begining of this header file)

Definition at line 76 of file msg_queue.c.

References MsgQueue::heap, MsgQueue::mb, MsgPtrLen::msg_ptr_len, MSGQ_HEAP, MsgQueue_INVALID_PTR, MsgQueue_MAILBOX_FULL, MsgQueue_REGULAR, tlsf_free_r(), and tlsf_get_heap_addr().

Referenced by msgqueue_copy_send_timeout(), and msgqueue_send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const char* msgqueue_strerror ( const MsgQueueStatus  errno)

debug api

give ascii string corresponding to the given errno

Parameters
[in]errno: staus
Returns
pointer to error string

Definition at line 168 of file msg_queue.c.

References _strerror, and MsgQueue_MAILBOX_FULL.

Variable Documentation

const char* _strerror[]
static
Initial value:
= {"MsgQueue_MAILBOX_FULL",
"MsgQueue_MAILBOX_FAIL",
"MsgQueue_MAILBOX_TIMEOUT",
"MsgQueue_MAILBOX_NOT_EMPTY",
"MsgQueue_OK",
"MsgQueue_INVALID_PTR",
"MsgQueue_INVALID_ERRNO"
}

Definition at line 159 of file msg_queue.c.

Referenced by msgqueue_strerror().