F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
QueueCommon.cpp
Go to the documentation of this file.
1#include <Os/Queue.hpp>
2#include <Fw/Types/Assert.hpp>
3#include <cstring>
4
5namespace Os {
6
7#if FW_QUEUE_REGISTRATION
8 QueueRegistry* Queue::s_queueRegistry = nullptr;
9#endif
10
12
14
15 const U8* msgBuff = buffer.getBuffAddr();
16 NATIVE_INT_TYPE buffLength = buffer.getBuffLength();
17
18 return this->send(msgBuff,buffLength,priority, block);
19
20 }
21
23
24 U8* msgBuff = buffer.getBuffAddr();
25 NATIVE_INT_TYPE buffCapacity = buffer.getBuffCapacity();
26 NATIVE_INT_TYPE recvSize = 0;
27
28 Queue::QueueStatus recvStat = this->receive(msgBuff, buffCapacity, recvSize, priority, block);
29
30 if (QUEUE_OK == recvStat) {
31 if (buffer.setBuffLen(recvSize) == Fw::FW_SERIALIZE_OK) {
32 return QUEUE_OK;
33 } else {
35 }
36 } else {
37 return recvStat;
38 }
39 }
40
42 FW_ASSERT(depth > 0, depth);
43 FW_ASSERT(msgSize > 0, depth);
44 return createInternal(name, depth, msgSize);
45 }
46
47
48#if FW_QUEUE_REGISTRATION
49
50 void Queue::setQueueRegistry(QueueRegistry* reg) {
51 // NULL is okay if a deregistration is desired
52 Queue::s_queueRegistry = reg;
53 }
54
55#endif
56
58 return Queue::s_numQueues;
59 }
60
62 return this->m_name;
63 }
64
65}
#define FW_ASSERT(...)
Definition Assert.hpp:7
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:26
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
virtual NATIVE_UINT_TYPE getBuffCapacity() const =0
returns capacity, not current size, of buffer
virtual U8 * getBuffAddr()=0
gets buffer address for data filling
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
QueueString m_name
queue name
Definition Queue.hpp:76
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
@ QUEUE_SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
Definition Queue.hpp:31
@ QUEUE_OK
message sent/received okay
Definition Queue.hpp:28
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
QueueStatus createInternal(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition Queue.cpp:42
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
const QueueString & getName()
get the queue name
QueueBlocking
Definition Queue.hpp:40
static NATIVE_INT_TYPE getNumQueues()
get the number of queues in the system
static NATIVE_INT_TYPE s_numQueues
tracks number of queues in the system
Definition Queue.hpp:80
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition File.cpp:6