Skip to content

Commit

Permalink
Feat/add task name (#64)
Browse files Browse the repository at this point in the history
* add task name

* set max size to valid size

* fix posix build

* format
  • Loading branch information
xgroleau authored Nov 20, 2021
1 parent 026accd commit 1d516c1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/os/freertos/include/AbstractTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class AbstractTask : public IAbstractTask {

bool start() override;

const char* getTaskName() override;

bool isRunning() override;

TaskHandle_t getTaskHandle() override;
Expand Down
5 changes: 5 additions & 0 deletions src/os/freertos/include/AbstractTask.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ bool AbstractTask<stackSize>::start() {
return false;
}

template <unsigned int stackSize>
const char* AbstractTask<stackSize>::getTaskName() {
return m_taskName;
}

template <unsigned int stackSize>
bool AbstractTask<stackSize>::isRunning() {
return m_taskRunning;
Expand Down
6 changes: 6 additions & 0 deletions src/os/include/IAbstractTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class IAbstractTask {
**/
virtual bool start() = 0;

/**
*@brief Gets the name of the task
*@return returns a pointer to the name of the task
**/
virtual const char* getTaskName() = 0;

/**
*@brief check if the task is currently running
*
Expand Down
4 changes: 4 additions & 0 deletions src/os/posix/include/AbstractTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "IAbstractTask.h"
#include "OSMacros.h"
#include <stdint.h>
#include <string>
#include <thread>

template <unsigned int stackSize>
Expand All @@ -15,6 +16,8 @@ class AbstractTask : public IAbstractTask {

bool start() override;

const char* getTaskName() override;

bool isRunning() override;

TaskHandle_t getTaskHandle() override;
Expand All @@ -24,6 +27,7 @@ class AbstractTask : public IAbstractTask {

static void wrapper(void* params);

const char* m_taskName;
bool m_taskRunning = false;
std::thread m_thread;
};
Expand Down
9 changes: 7 additions & 2 deletions src/os/posix/include/AbstractTask.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define ABSTRACTTASK_TPP

template <unsigned int stackSize>
AbstractTask<stackSize>::AbstractTask(const char* taskName, UBaseType_t priority) {
(void)taskName;
AbstractTask<stackSize>::AbstractTask(const char* taskName, UBaseType_t priority) :
m_taskName(taskName) {
(void)priority;
}

Expand All @@ -28,6 +28,11 @@ bool AbstractTask<stackSize>::start() {
return false;
}

template <unsigned int stackSize>
const char* AbstractTask<stackSize>::getTaskName() {
return m_taskName;
}

template <unsigned int stackSize>
bool AbstractTask<stackSize>::isRunning() {
return m_taskRunning;
Expand Down
4 changes: 2 additions & 2 deletions src/pheromones/src/HiveMindHostAccumulatorSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ bool HiveMindHostAccumulatorSerializer::serializeToStream(const MessageDTO& mess
Message msgSend;
message.serialize(msgSend);

pb_ostream_t outputStream{HiveMindHostAccumulatorSerializer::streamCallback, this, SIZE_MAX, 0,
0};
pb_ostream_t outputStream{HiveMindHostAccumulatorSerializer::streamCallback, this,
2 * Message_size, 0, 0};

if (pb_encode_ex(&outputStream, Message_fields, &msgSend, PB_ENCODE_DELIMITED)) {
bool ret = m_stream.send(m_data.data(), m_messageLength);
Expand Down
2 changes: 1 addition & 1 deletion src/pheromones/src/HiveMindHostSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bool HiveMindHostSerializer::serializeToStream(const MessageDTO& message) {
Message msgSend;
message.serialize(msgSend);

pb_ostream_t outputStream{HiveMindHostSerializer::streamCallback, this, SIZE_MAX, 0, 0};
pb_ostream_t outputStream{HiveMindHostSerializer::streamCallback, this, 2 * Message_size, 0, 0};

return pb_encode_ex(&outputStream, Message_fields, &msgSend, PB_ENCODE_DELIMITED);
}
Expand Down

0 comments on commit 1d516c1

Please sign in to comment.