5 #ifdef TGT_OS_TYPE_VXWORKS
9 #ifdef TGT_OS_TYPE_LINUX
10 #include <sys/types.h>
24 #define IPC_QUEUE_TIMEOUT_SEC (1)
36 (void) mq_close(this->
handle);
49 #ifndef TGT_OS_TYPE_VXWORKS
51 (void)snprintf(pid,
sizeof(pid),
".%d",getpid());
52 pid[
sizeof(pid)-1] = 0;
58 memset(&att,0,
sizeof(att));
59 att.mq_maxmsg = depth;
60 att.mq_msgsize = msgSize;
68 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
74 (void)mq_unlink(this->m_name.toChar());
80 handle = mq_open(this->m_name.toChar(), O_RDWR | O_CREAT | O_EXCL, 0666, &att);
88 QueueHandle* queueHandle =
new(std::nothrow) QueueHandle(handle);
89 if (
nullptr == queueHandle) {
101 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
102 if (
nullptr != queueHandle) {
106 (void) mq_unlink(this->m_name.toChar());
111 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
112 mqd_t handle = queueHandle->handle;
118 if (
nullptr == buffer) {
122 bool keepTrying =
true;
125 gettimeofday(&now,
nullptr);
126 struct timespec wait;
127 wait.tv_sec = now.tv_sec;
128 wait.tv_nsec = now.tv_usec * 1000;
136 reinterpret_cast<const char*
>(buffer),
137 static_cast<size_t>(size),
138 static_cast<unsigned int>(priority),
174 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
175 mqd_t handle = queueHandle->handle;
182 bool notFinished =
true;
183 while (notFinished) {
185 gettimeofday(&now,
nullptr);
186 struct timespec wait;
187 wait.tv_sec = now.tv_sec;
188 wait.tv_nsec = now.tv_usec * 1000;
193 size = mq_timedreceive(handle,
reinterpret_cast<char*
>(buffer),
static_cast<size_t>(capacity),
194 #ifdef TGT_OS_TYPE_VXWORKS
195 reinterpret_cast<int*
>(&priority), &wait);
197 reinterpret_cast<unsigned int*
>(&priority), &wait);
233 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
234 mqd_t handle = queueHandle->handle;
237 int status = mq_getattr(handle, &attr);
248 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
249 mqd_t handle = queueHandle->handle;
252 int status = mq_getattr(handle, &attr);
258 QueueHandle* queueHandle =
reinterpret_cast<QueueHandle*
>(this->
m_handle);
259 mqd_t handle = queueHandle->handle;
262 int status = mq_getattr(handle, &attr);
PlatformPointerCastType POINTER_CAST
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
#define IPC_QUEUE_TIMEOUT_SEC
NATIVE_INT_TYPE getQueueSize() const
get the queue depth (maximum number of messages queue can hold)
NATIVE_INT_TYPE getMsgSize() const
get the message size (maximum message size queue can hold)
QueueStatus create(const Fw::StringBase &name, NATIVE_INT_TYPE depth, NATIVE_INT_TYPE msgSize)
create a message queue
QueueStatus send(const Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE priority, QueueBlocking block)
send a message
NATIVE_INT_TYPE getNumMsgs() const
get the number of messages in the queue
QueueStatus receive(Fw::SerializeBufferBase &buffer, NATIVE_INT_TYPE &priority, QueueBlocking block)
receive a message
NATIVE_INT_TYPE getMaxMsgs() const
get the maximum number of messages (high watermark)
QueueHandle(mqd_t m_handle)
QueueString m_name
queue name
@ QUEUE_SIZE_MISMATCH
attempted to send or receive with buffer too large, too small
@ QUEUE_UNINITIALIZED
Queue wasn't initialized successfully.
@ QUEUE_NO_MORE_MSGS
If non-blocking, all the messages have been drained.
@ QUEUE_INVALID_PRIORITY
invalid priority requested
@ QUEUE_EMPTY_BUFFER
supplied buffer is empty
@ QUEUE_UNKNOWN_ERROR
Unexpected error; can't match with returns.
@ QUEUE_OK
message sent/received okay
@ QUEUE_FULL
queue was full when attempting to send a message
@ QUEUE_BLOCKING
Queue receive blocks until a message arrives.
@ QUEUE_NONBLOCKING
Queue receive always returns even if there is no message.
static NATIVE_INT_TYPE s_numQueues
tracks number of queues in the system
POINTER_CAST m_handle
handle for implementation specific queue