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