Merge pull request 'Host OSAL bugfixes' (#289) from mueller/host-osal-atomic into development
Reviewed-on: fsfw/fsfw#289
This commit is contained in:
commit
aa3fe1e7f0
@ -46,7 +46,7 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority,
|
||||
<< GetLastError() << std::endl;
|
||||
}
|
||||
#elif defined(LINUX)
|
||||
// we can just copy and paste the code from linux here.
|
||||
// TODO: we can just copy and paste the code from the linux OSAL here.
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -116,7 +116,8 @@ void FixedTimeslotTask::taskFunctionality() {
|
||||
if (not pollingSeqTable.slotFollowsImmediately()) {
|
||||
// we need to wait before executing the current slot
|
||||
// this gives us the time to wait:
|
||||
interval = chron_ms(this->pollingSeqTable.getIntervalToPreviousSlotMs());
|
||||
interval = chron_ms(
|
||||
this->pollingSeqTable.getIntervalToPreviousSlotMs());
|
||||
delayForInterval(¤tStartTime, interval);
|
||||
//TODO deadline missed check
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ protected:
|
||||
//!< Typedef for the List of objects.
|
||||
typedef std::vector<ExecutableObjectIF*> ObjectList;
|
||||
std::thread mainThread;
|
||||
std::atomic<bool> terminateThread = false;
|
||||
std::atomic<bool> terminateThread { false };
|
||||
|
||||
//! Polling sequence table which contains the object to execute
|
||||
//! and information like the timeslots and the passed execution step.
|
||||
|
@ -4,21 +4,18 @@
|
||||
Mutex::Mutex() {}
|
||||
|
||||
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
if(timeoutMs == MutexIF::BLOCKING) {
|
||||
if(timeoutType == MutexIF::BLOCKING) {
|
||||
mutex.lock();
|
||||
locked = true;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
else if(timeoutMs == MutexIF::POLLING) {
|
||||
else if(timeoutType == MutexIF::POLLING) {
|
||||
if(mutex.try_lock()) {
|
||||
locked = true;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
else if(timeoutMs > MutexIF::POLLING){
|
||||
auto chronoMs = std::chrono::milliseconds(timeoutMs);
|
||||
if(mutex.try_lock_for(chronoMs)) {
|
||||
locked = true;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
@ -26,11 +23,7 @@ ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||
}
|
||||
|
||||
ReturnValue_t Mutex::unlockMutex() {
|
||||
if(not locked) {
|
||||
return MutexIF::CURR_THREAD_DOES_NOT_OWN_MUTEX;
|
||||
}
|
||||
mutex.unlock();
|
||||
locked = false;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public:
|
||||
|
||||
std::timed_mutex* getMutexHandle();
|
||||
private:
|
||||
bool locked = false;
|
||||
//bool locked = false;
|
||||
std::timed_mutex mutex;
|
||||
};
|
||||
|
||||
|
@ -89,6 +89,10 @@ ReturnValue_t PeriodicTask::sleepFor(uint32_t ms) {
|
||||
}
|
||||
|
||||
void PeriodicTask::taskFunctionality() {
|
||||
for (const auto& object: objectList) {
|
||||
object->initializeAfterTaskCreation();
|
||||
}
|
||||
|
||||
std::chrono::milliseconds periodChrono(static_cast<uint32_t>(period*1000));
|
||||
auto currentStartTime {
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
@ -101,13 +105,10 @@ void PeriodicTask::taskFunctionality() {
|
||||
if(terminateThread.load()) {
|
||||
break;
|
||||
}
|
||||
for (ObjectList::iterator it = objectList.begin();
|
||||
it != objectList.end(); ++it) {
|
||||
(*it)->performOperation();
|
||||
for (const auto& object: objectList) {
|
||||
object->performOperation();
|
||||
}
|
||||
if(not delayForInterval(¤tStartTime, periodChrono)) {
|
||||
sif::warning << "PeriodicTask: " << taskName <<
|
||||
" missed deadline!\n" << std::flush;
|
||||
if(deadlineMissedFunc != nullptr) {
|
||||
this->deadlineMissedFunc();
|
||||
}
|
||||
@ -121,6 +122,7 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
||||
if (newObject == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
newObject->setTaskIF(this);
|
||||
objectList.push_back(newObject);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ protected:
|
||||
//!< Typedef for the List of objects.
|
||||
typedef std::vector<ExecutableObjectIF*> ObjectList;
|
||||
std::thread mainThread;
|
||||
std::atomic<bool> terminateThread = false;
|
||||
std::atomic<bool> terminateThread { false };
|
||||
|
||||
/**
|
||||
* @brief This attribute holds a list of objects to be executed.
|
||||
|
@ -6,6 +6,7 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId,
|
||||
uint16_t serverPort, uint16_t clientPort):
|
||||
TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
communicationLinkUp = false;
|
||||
|
||||
// Initiates Winsock DLL.
|
||||
WSAData wsaData;
|
||||
@ -90,7 +91,6 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
||||
// sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were"
|
||||
// " sent." << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) {
|
||||
@ -101,6 +101,7 @@ void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) {
|
||||
// &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
|
||||
// sif::debug << "IP Address Old: " << inet_ntop(AF_INET,
|
||||
// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
|
||||
registerCommConnect();
|
||||
|
||||
// Set new IP address if it has changed.
|
||||
if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) {
|
||||
@ -114,7 +115,7 @@ void TmTcWinUdpBridge::handleSocketError() {
|
||||
switch(errCode) {
|
||||
case(WSANOTINITIALISED): {
|
||||
sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: "
|
||||
<< "WSAStartup(...) call " << "necessary" << std::endl;
|
||||
<< "WSAStartup(...) call necessary" << std::endl;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -154,11 +155,11 @@ void TmTcWinUdpBridge::handleSendError() {
|
||||
switch(errCode) {
|
||||
case(WSANOTINITIALISED): {
|
||||
sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: "
|
||||
<< "WSAStartup(...) call " << "necessary" << std::endl;
|
||||
<< "WSAStartup(...) call necessary" << std::endl;
|
||||
break;
|
||||
}
|
||||
case(WSAEADDRNOTAVAIL): {
|
||||
sif::info << "TmTcWinUdpBridge::handleReadError: WSAEADDRNOTAVAIL: "
|
||||
sif::info << "TmTcWinUdpBridge::handleSendError: WSAEADDRNOTAVAIL: "
|
||||
<< "Check target address. " << std::endl;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user