F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QueueCommon.cpp
Go to the documentation of this file.
1 #include <Os/Queue.hpp>
2 #include <Fw/Types/Assert.hpp>
3 #include <string.h>
4 
5 namespace Os {
6 
7 #if FW_QUEUE_REGISTRATION
8  QueueRegistry* Queue::s_queueRegistry = 0;
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 {
34  return QUEUE_SIZE_MISMATCH;
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 
61  const QueueString& Queue::getName(void) {
62  return this->m_name;
63  }
64 
65 }
Os::Queue::getName
const QueueString & getName(void)
get the queue name
Definition: QueueCommon.cpp:61
Os
Definition: File.cpp:7
Os::Queue::create
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: QueueCommon.cpp:41
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Fw::StringBase
Definition: StringType.hpp:23
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
Os::Queue::QueueStatus
QueueStatus
Definition: Queue.hpp:27
Assert.hpp
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Os::Queue::send
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
Definition: QueueCommon.cpp:13
Fw::SerializeBufferBase::getBuffAddr
virtual U8 * getBuffAddr(void)=0
gets buffer address for data filling
Os::Queue::QUEUE_SIZE_MISMATCH
@ QUEUE_SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
Definition: Queue.hpp:31
Os::Queue::QueueBlocking
QueueBlocking
Definition: Queue.hpp:40
Fw::SerializeBufferBase::getBuffCapacity
virtual NATIVE_UINT_TYPE getBuffCapacity(void) const =0
returns capacity, not current size, of buffer
Os::Queue::receive
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
Definition: QueueCommon.cpp:22
Os::QueueRegistry
Definition: Queue.hpp:87
Os::QueueString
Definition: QueueString.hpp:10
Os::Queue::m_name
QueueString m_name
queue name
Definition: Queue.hpp:76
Fw::SerializeBufferBase::setBuffLen
SerializeStatus setBuffLen(NATIVE_UINT_TYPE length)
sets buffer length manually after filling with data
Definition: Serializable.cpp:604
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:587
Os::Queue::QUEUE_OK
@ QUEUE_OK
message sent/received okay
Definition: Queue.hpp:28
Os::Queue::s_numQueues
static NATIVE_INT_TYPE s_numQueues
tracks number of queues in the system
Definition: Queue.hpp:80
Os::Queue::getNumQueues
static NATIVE_INT_TYPE getNumQueues(void)
get the number of queues in the system
Definition: QueueCommon.cpp:57
Os::Queue::createInternal
QueueStatus createInternal(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
Definition: Queue.cpp:41
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Queue.hpp