add lock, use generic sem interface
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
parent
de66ac66c6
commit
826f4ce29c
@ -3,6 +3,7 @@
|
||||
#include <etl/crc16_ccitt.h>
|
||||
#include <fcntl.h> // Contains file controls like O_RDWR
|
||||
#include <fsfw/filesystem/HasFileSystemIF.h>
|
||||
#include <fsfw/tasks/SemaphoreFactory.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cmath>
|
||||
@ -27,6 +28,9 @@ using namespace returnvalue;
|
||||
PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId), ringBuf(4096, true) {
|
||||
spParams.maxSize = sizeof(commandBuffer);
|
||||
resetSpParams();
|
||||
semaphore = SemaphoreFactory::instance()->createBinarySemaphore();
|
||||
semaphore->acquire();
|
||||
lock = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
PlocSupvHelper::~PlocSupvHelper() {}
|
||||
@ -44,11 +48,11 @@ ReturnValue_t PlocSupvHelper::initialize() {
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
semaphore.acquire();
|
||||
semaphore->acquire();
|
||||
while (true) {
|
||||
switch (internalState) {
|
||||
case InternalState::IDLE: {
|
||||
semaphore.acquire();
|
||||
semaphore->acquire();
|
||||
break;
|
||||
}
|
||||
case InternalState::UPDATE: {
|
||||
@ -164,7 +168,7 @@ ReturnValue_t PlocSupvHelper::performUpdate(const supv::UpdateParams& params) {
|
||||
update.sequenceCount = params.seqCount;
|
||||
internalState = InternalState::UPDATE;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore.release();
|
||||
semaphore->release();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -183,13 +187,13 @@ ReturnValue_t PlocSupvHelper::performMemCheck(uint8_t memoryId, uint32_t startAd
|
||||
update.crcShouldBeChecked = checkCrc;
|
||||
internalState = InternalState::CHECK_MEMORY;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore.release();
|
||||
semaphore->release();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::initiateUpdateContinuation() {
|
||||
internalState = InternalState::CONTINUE_UPDATE;
|
||||
semaphore.release();
|
||||
semaphore->release();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::startEventBufferRequest(std::string path) {
|
||||
@ -205,7 +209,7 @@ ReturnValue_t PlocSupvHelper::startEventBufferRequest(std::string path) {
|
||||
eventBufferReq.path = path;
|
||||
internalState = InternalState::REQUEST_EVENT_BUFFER;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore.release();
|
||||
semaphore->release();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
|
@ -186,6 +186,8 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
||||
|
||||
struct Update update;
|
||||
|
||||
SemaphoreIF* semaphore;
|
||||
MutexIF* lock;
|
||||
int serialPort = 0;
|
||||
struct termios tty = {};
|
||||
|
||||
@ -202,7 +204,6 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
||||
|
||||
InternalState internalState = InternalState::IDLE;
|
||||
|
||||
BinarySemaphore semaphore;
|
||||
#ifdef XIPHOS_Q7S
|
||||
SdCardManager* sdcMan = nullptr;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user