if I do use a binary semaphore and initialize in the ctor sem = xSemaphoreCreateBinary();
, I suspect xSemaphoreTake
causes the current task to be blocked. Perhaps I was looking from a mutex perspective that gives exclusive rights to the said task rather than blocking it.
So maybe I want something like this but is this the preferred approach?
template<typename... Args>
void Print(const char* format, Args... args)
{
char buffer[100] = {0};
std::snprintf(buffer, sizeof(buffer), format, args...);
std::strcat(buffer, "\r\n");
size_t length = strlen(buffer);
TXInterrupt(reinterpret_cast<T*> (buffer), length);
xSemaphoreTake(sem, portMAX_DELAY); // "wait" till the TX transmission is done
}
}