diff --git a/source/shoh/src/main.cpp b/source/shoh/src/main.cpp index c226edb..d49e58c 100644 --- a/source/shoh/src/main.cpp +++ b/source/shoh/src/main.cpp @@ -27,7 +27,7 @@ int main(void) QueueHandle_t master_event_all_q = qmanager->getQueue(ThreadCommon::QueueManager::master_event_all); ThreadCommon::Event* e = new ThreadCommon::Event(ThreadCommon::Null, 0); - xQueueSend(master_event_all_q, static_cast(e), 0); + qmanager->send(ThreadCommon::QueueManager::master_event_all, e, 1000); // // Start the real time kernel with preemption. diff --git a/source/shoh/src/threads/common/ThreadCommon.h b/source/shoh/src/threads/common/ThreadCommon.h index 071e2ab..be6b149 100644 --- a/source/shoh/src/threads/common/ThreadCommon.h +++ b/source/shoh/src/threads/common/ThreadCommon.h @@ -76,6 +76,21 @@ namespace ThreadCommon ~QueueManager() = default; bool createQueue(size_t queue_length, size_t item_size, Queue_id qid); QueueHandle_t getQueue(Queue_id qid); + template bool send(Queue_id qid, T* data, TickType_t timeout){ + QueueHandle_t q = this->getQueue(qid); + BaseType_t qCheck = xQueueSend(q, + static_cast(data), + timeout); + return (qCheck == pdTRUE); + } + template bool receive(Queue_id qid, T* data, TickType_t timeout){ + QueueHandle_t q = this->getQueue(qid); + BaseType_t qCheck = xQueueReceive(q, + static_cast(data), + timeout); + return (qCheck == pdTRUE); + } + private: std::map queues; }; diff --git a/source/shoh/src/threads/master/Master.cpp b/source/shoh/src/threads/master/Master.cpp index 3f7a9cc..411baaa 100644 --- a/source/shoh/src/threads/master/Master.cpp +++ b/source/shoh/src/threads/master/Master.cpp @@ -13,12 +13,11 @@ Master::Master(ThreadCommon::QueueManager* qm) : _qm(qm) } void Master::taskFunction() { - QueueHandle_t master_event_all_q = _qm->getQueue(ThreadCommon::QueueManager::master_event_all); ThreadCommon::Event data(ThreadCommon::Null, 0); int led = 0; bool LedState = true; for (;;) { - xQueueReceive(master_event_all_q, static_cast(&data), portMAX_DELAY); + _qm->receive(ThreadCommon::QueueManager::master_event_all, &data, portMAX_DELAY); Board_LED_Set(led, LedState); LedState = (bool) !LedState; led++;