size check for message queue
This commit is contained in:
parent
45a55044dd
commit
109fdad8b3
@ -7,7 +7,8 @@
|
|||||||
// As a first step towards this, introduces system context variable which needs
|
// As a first step towards this, introduces system context variable which needs
|
||||||
// to be switched manually
|
// to be switched manually
|
||||||
// Haven't found function to find system context.
|
// Haven't found function to find system context.
|
||||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize) {
|
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||||
|
maxMessageSize(maxMessageSize) {
|
||||||
handle = xQueueCreate(messageDepth, maxMessageSize);
|
handle = xQueueCreate(messageDepth, maxMessageSize);
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
sif::error << "MessageQueue: Creation failed" << std::endl;
|
sif::error << "MessageQueue: Creation failed" << std::endl;
|
||||||
@ -120,10 +121,16 @@ bool MessageQueue::isDefaultDestinationSet() const {
|
|||||||
|
|
||||||
// static core function to send messages.
|
// static core function to send messages.
|
||||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||||
MessageQueueMessageIF *message, MessageQueueId_t sentFrom,
|
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||||
bool ignoreFault, CallContext callContext) {
|
bool ignoreFault, CallContext callContext) {
|
||||||
message->setSender(sentFrom);
|
message->setSender(sentFrom);
|
||||||
BaseType_t result;
|
BaseType_t result;
|
||||||
|
if(message->getMaximumMessageSize() > maxMessageSize) {
|
||||||
|
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message size"
|
||||||
|
"too large for queue!" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if(callContext == CallContext::TASK) {
|
if(callContext == CallContext::TASK) {
|
||||||
result = xQueueSendToBack(reinterpret_cast<QueueHandle_t>(sendTo),
|
result = xQueueSendToBack(reinterpret_cast<QueueHandle_t>(sendTo),
|
||||||
static_cast<const void*>(message->getBuffer()), 0);
|
static_cast<const void*>(message->getBuffer()), 0);
|
||||||
|
@ -204,6 +204,7 @@ private:
|
|||||||
QueueHandle_t handle;
|
QueueHandle_t handle;
|
||||||
MessageQueueId_t defaultDestination = 0;
|
MessageQueueId_t defaultDestination = 0;
|
||||||
MessageQueueId_t lastPartner = 0;
|
MessageQueueId_t lastPartner = 0;
|
||||||
|
const size_t maxMessageSize;
|
||||||
//!< Stores the current system context
|
//!< Stores the current system context
|
||||||
CallContext callContext = CallContext::TASK;
|
CallContext callContext = CallContext::TASK;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user