important replacements
This commit is contained in:
parent
c815905b5a
commit
3e9c19ee11
@ -1,5 +1,5 @@
|
|||||||
#ifndef FRAMEWORK_IPC_MUTEXHELPER_H_
|
#ifndef FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||||
#define FRAMEWORK_IPC_MUTEXHELPER_H_
|
#define FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||||
|
|
||||||
#include "MutexFactory.h"
|
#include "MutexFactory.h"
|
||||||
#include "../serviceinterface/ServiceInterface.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
@ -12,9 +12,9 @@ public:
|
|||||||
if(mutex == nullptr) {
|
if(mutex == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexHelper: Passed mutex is invalid!" << std::endl;
|
sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexHelper: Passed mutex is invalid!\n");
|
sif::printError("MutexGuard: Passed mutex is invalid!\n");
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return;
|
return;
|
||||||
@ -24,19 +24,19 @@ public:
|
|||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
if(result == MutexIF::MUTEX_TIMEOUT) {
|
if(result == MutexIF::MUTEX_TIMEOUT) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexHelper: Lock of mutex failed with timeout of "
|
sif::error << "MutexGuard: Lock of mutex failed with timeout of "
|
||||||
<< timeoutMs << " milliseconds!" << std::endl;
|
<< timeoutMs << " milliseconds!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexHelper: Lock of mutex failed with timeout of %lu milliseconds\n",
|
sif::printError("MutexGuard: Lock of mutex failed with timeout of %lu milliseconds\n",
|
||||||
timeoutMs);
|
timeoutMs);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(result != HasReturnvaluesIF::RETURN_OK) {
|
else if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexHelper: Lock of Mutex failed with code " << result << std::endl;
|
sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexHelper: Lock of Mutex failed with code %d\n", result);
|
sif::printError("MutexGuard: Lock of Mutex failed with code %d\n", result);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -59,4 +59,4 @@ private:
|
|||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FRAMEWORK_IPC_MUTEXHELPER_H_ */
|
#endif /* FRAMEWORK_IPC_MUTEXGUARD_H_ */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||||
messageSize(maxMessageSize), messageDepth(messageDepth) {
|
messageSize(maxMessageSize), messageDepth(messageDepth) {
|
||||||
@ -65,7 +65,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
|||||||
}
|
}
|
||||||
// not sure this will work..
|
// not sure this will work..
|
||||||
//*message = std::move(messageQueue.front());
|
//*message = std::move(messageQueue.front());
|
||||||
MutexHelper mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
MutexGuard mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
||||||
MessageQueueMessage* currentMessage = &messageQueue.front();
|
MessageQueueMessage* currentMessage = &messageQueue.front();
|
||||||
std::copy(currentMessage->getBuffer(),
|
std::copy(currentMessage->getBuffer(),
|
||||||
currentMessage->getBuffer() + messageSize, message->getBuffer());
|
currentMessage->getBuffer() + messageSize, message->getBuffer());
|
||||||
@ -130,7 +130,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
||||||
MutexHelper mutexLock(targetQueue->queueLock,
|
MutexGuard mutexLock(targetQueue->queueLock,
|
||||||
MutexIF::TimeoutType::WAITING, 20);
|
MutexIF::TimeoutType::WAITING, 20);
|
||||||
// not ideal, works for now though.
|
// not ideal, works for now though.
|
||||||
MessageQueueMessage* mqmMessage =
|
MessageQueueMessage* mqmMessage =
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "../../serviceinterface/ServiceInterface.h"
|
#include "../../serviceinterface/ServiceInterface.h"
|
||||||
#include "../../ipc/MutexFactory.h"
|
#include "../../ipc/MutexFactory.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
QueueMapManager* QueueMapManager::mqManagerInstance = nullptr;
|
QueueMapManager* QueueMapManager::mqManagerInstance = nullptr;
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ ReturnValue_t QueueMapManager::addMessageQueue(
|
|||||||
|
|
||||||
MessageQueueIF* QueueMapManager::getMessageQueue(
|
MessageQueueIF* QueueMapManager::getMessageQueue(
|
||||||
MessageQueueId_t messageQueueId) const {
|
MessageQueueId_t messageQueueId) const {
|
||||||
MutexHelper(mapLock, MutexIF::TimeoutType::WAITING, 50);
|
MutexGuard(mapLock, MutexIF::TimeoutType::WAITING, 50);
|
||||||
auto queueIter = queueMap.find(messageQueueId);
|
auto queueIter = queueMap.find(messageQueueId);
|
||||||
if(queueIter != queueMap.end()) {
|
if(queueIter != queueMap.end()) {
|
||||||
return queueIter->second;
|
return queueIter->second;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "RtemsBasic.h"
|
#include "RtemsBasic.h"
|
||||||
|
|
||||||
#include "../../timemanager/Clock.h"
|
#include "../../timemanager/Clock.h"
|
||||||
#include "../../ipc/MutexHelper.h"
|
#include "../../ipc/MutexGuard.h"
|
||||||
|
|
||||||
#include <rtems/score/todimpl.h>
|
#include <rtems/score/todimpl.h>
|
||||||
#include <rtems/rtems/clockimpl.h>
|
#include <rtems/rtems/clockimpl.h>
|
||||||
@ -183,7 +183,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
|||||||
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
MutexHelper helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
|
||||||
|
|
||||||
leapSeconds = leapSeconds_;
|
leapSeconds = leapSeconds_;
|
||||||
@ -196,7 +196,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
|||||||
if(timeMutex==nullptr){
|
if(timeMutex==nullptr){
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
MutexHelper helper(timeMutex);
|
MutexGuard helper(timeMutex);
|
||||||
|
|
||||||
*leapSeconds_ = leapSeconds;
|
*leapSeconds_ = leapSeconds;
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#include <fsfw/ipc/MutexHelper.h>
|
|
||||||
#include "TmTcWinUdpBridge.h"
|
#include "TmTcWinUdpBridge.h"
|
||||||
|
|
||||||
|
#include <fsfw/ipc/MutexGuard.h>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
typedef SSIZE_T ssize_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId,
|
TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId,
|
||||||
object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId,
|
object_id_t tcDestination, object_id_t tmStoreId, object_id_t tcStoreId,
|
||||||
uint16_t serverPort, uint16_t clientPort):
|
uint16_t serverPort, uint16_t clientPort):
|
||||||
|
Loading…
Reference in New Issue
Block a user