printf support

This commit is contained in:
Robin Müller 2021-01-27 18:15:54 +01:00
parent 8b5abd1fd5
commit a0e7b45d94
2 changed files with 8 additions and 6 deletions

View File

@ -1,18 +1,20 @@
#include "Mutex.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include "../../serviceinterface/ServiceInterface.h"
uint8_t Mutex::count = 0;
Mutex::Mutex() :
mutexId(0) {
Mutex::Mutex() {
rtems_name mutexName = ('M' << 24) + ('T' << 16) + ('X' << 8) + count++;
rtems_status_code status = rtems_semaphore_create(mutexName, 1,
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, 0,
&mutexId);
if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: creation with name, id " << mutexName << ", " << mutexId
<< " failed with " << status << std::endl;
sif::error << "Mutex::Mutex: Creation with name, id " << mutexName << ", " << mutexId <<
" failed with " << status << std::endl;
#else
sif::printError("Mutex::Mutex: Creation with name, id %s, %d failed with %d\n", mutexName,
static_cast<int>(mutexId), static_cast<int>(status));
#endif
}
}

View File

@ -11,7 +11,7 @@ public:
ReturnValue_t lockMutex(TimeoutType timeoutType, uint32_t timeoutMs = 0);
ReturnValue_t unlockMutex();
private:
rtems_id mutexId;
rtems_id mutexId = 0;
static uint8_t count;
};