PLOC SUPV Update to newer firmware #316
@ -33,7 +33,7 @@ PlocSupvHelper::PlocSupvHelper(object_id_t objectId) : SystemObject(objectId), r
|
|||||||
lock = MutexFactory::instance()->createMutex();
|
lock = MutexFactory::instance()->createMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlocSupvHelper::~PlocSupvHelper() {}
|
PlocSupvHelper::~PlocSupvHelper() = default;
|
||||||
|
|
||||||
ReturnValue_t PlocSupvHelper::initialize() {
|
ReturnValue_t PlocSupvHelper::initialize() {
|
||||||
#ifdef XIPHOS_Q7S
|
#ifdef XIPHOS_Q7S
|
||||||
@ -47,59 +47,102 @@ 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;
|
||||||
semaphore->acquire();
|
lock->lockMutex();
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
lock->unlockMutex();
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (internalState) {
|
semaphore->acquire();
|
||||||
case InternalState::IDLE: {
|
int bytesRead = 0;
|
||||||
semaphore->acquire();
|
while (true) {
|
||||||
break;
|
bytesRead = read(serialPort, reinterpret_cast<void*>(recBuf.data()),
|
||||||
}
|
static_cast<unsigned int>(recBuf.size()));
|
||||||
case InternalState::UPDATE: {
|
if (bytesRead == 0) {
|
||||||
result = executeUpdate();
|
{
|
||||||
if (result == returnvalue::OK) {
|
MutexGuard mg(lock);
|
||||||
triggerEvent(SUPV_UPDATE_SUCCESSFUL, result);
|
if (internalState == InternalState::FINISH) {
|
||||||
} else if (result == PROCESS_TERMINATED) {
|
// Flush received and unread data
|
||||||
// Event already triggered
|
tcflush(serialPort, TCIOFLUSH);
|
||||||
} else {
|
internalState = InternalState::IDLE;
|
||||||
triggerEvent(SUPV_UPDATE_FAILED, result);
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
internalState = InternalState::IDLE;
|
} else if (bytesRead < 0) {
|
||||||
|
sif::warning << "ScexUartReader::performOperation: read call failed with error [" << errno
|
||||||
|
<< ", " << strerror(errno) << "]" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
} else if (bytesRead >= static_cast<int>(recBuf.size())) {
|
||||||
case InternalState::CHECK_MEMORY: {
|
sif::error << "ScexUartReader::performOperation: Receive buffer too small for " << bytesRead
|
||||||
executeFullCheckMemoryCommand();
|
<< " bytes" << std::endl;
|
||||||
internalState = InternalState::IDLE;
|
} else if (bytesRead > 0) {
|
||||||
break;
|
if (debugMode) {
|
||||||
}
|
sif::info << "Received " << bytesRead
|
||||||
case InternalState::CONTINUE_UPDATE: {
|
<< " bytes from the Solar Cell Experiment:" << std::endl;
|
||||||
result = continueUpdate();
|
|
||||||
if (result == returnvalue::OK) {
|
|
||||||
triggerEvent(SUPV_CONTINUE_UPDATE_SUCCESSFUL, result);
|
|
||||||
} else if (result == PROCESS_TERMINATED) {
|
|
||||||
// Event already triggered
|
|
||||||
} else {
|
|
||||||
triggerEvent(SUPV_CONTINUE_UPDATE_FAILED, result);
|
|
||||||
}
|
}
|
||||||
internalState = InternalState::IDLE;
|
// insert buffer into ring buffer here
|
||||||
break;
|
// ReturnValue_t result = dleParser.passData(recBuf.data(), bytesRead);
|
||||||
|
// TODO: Parse ring buffer here
|
||||||
}
|
}
|
||||||
case InternalState::REQUEST_EVENT_BUFFER: {
|
lock->lockMutex();
|
||||||
result = performEventBufferRequest();
|
InternalState currentState = internalState;
|
||||||
if (result == returnvalue::OK) {
|
lock->unlockMutex();
|
||||||
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL, result);
|
switch (currentState) {
|
||||||
} else if (result == PROCESS_TERMINATED) {
|
case InternalState::IDLE: {
|
||||||
// Event already triggered
|
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
|
|
||||||
}
|
}
|
||||||
internalState = InternalState::IDLE;
|
case InternalState::UPDATE: {
|
||||||
break;
|
result = executeUpdate();
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
triggerEvent(SUPV_UPDATE_SUCCESSFUL, result);
|
||||||
|
} else if (result == PROCESS_TERMINATED) {
|
||||||
|
// Event already triggered
|
||||||
|
} else {
|
||||||
|
triggerEvent(SUPV_UPDATE_FAILED, result);
|
||||||
|
}
|
||||||
|
MutexGuard mg(lock);
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case InternalState::CHECK_MEMORY: {
|
||||||
|
executeFullCheckMemoryCommand();
|
||||||
|
MutexGuard mg(lock);
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case InternalState::CONTINUE_UPDATE: {
|
||||||
|
result = continueUpdate();
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
triggerEvent(SUPV_CONTINUE_UPDATE_SUCCESSFUL, result);
|
||||||
|
} else if (result == PROCESS_TERMINATED) {
|
||||||
|
// Event already triggered
|
||||||
|
} else {
|
||||||
|
triggerEvent(SUPV_CONTINUE_UPDATE_FAILED, result);
|
||||||
|
}
|
||||||
|
MutexGuard mg(lock);
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case InternalState::REQUEST_EVENT_BUFFER: {
|
||||||
|
result = performEventBufferRequest();
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
|
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL, result);
|
||||||
|
} else if (result == PROCESS_TERMINATED) {
|
||||||
|
// Event already triggered
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_FAILED, result);
|
||||||
|
}
|
||||||
|
MutexGuard mg(lock);
|
||||||
|
internalState = InternalState::IDLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case InternalState::HANDLER_DRIVEN: {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
sif::debug << "PlocSupvHelper::performOperation: Invalid state" << std::endl;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
sif::debug << "PlocSupvHelper::performOperation: Invalid state" << std::endl;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,13 +200,22 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
|||||||
|
|
||||||
EventBufferRequest eventBufferReq;
|
EventBufferRequest eventBufferReq;
|
||||||
|
|
||||||
enum class InternalState { IDLE, UPDATE, CONTINUE_UPDATE, REQUEST_EVENT_BUFFER, CHECK_MEMORY };
|
enum class InternalState {
|
||||||
|
IDLE,
|
||||||
|
HANDLER_DRIVEN,
|
||||||
|
UPDATE,
|
||||||
|
CONTINUE_UPDATE,
|
||||||
|
REQUEST_EVENT_BUFFER,
|
||||||
|
CHECK_MEMORY,
|
||||||
|
FINISH
|
||||||
|
};
|
||||||
|
|
||||||
InternalState internalState = InternalState::IDLE;
|
InternalState internalState = InternalState::IDLE;
|
||||||
|
|
||||||
#ifdef XIPHOS_Q7S
|
#ifdef XIPHOS_Q7S
|
||||||
SdCardManager* sdcMan = nullptr;
|
SdCardManager* sdcMan = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
std::array<uint8_t, 2048> recBuf = {};
|
||||||
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]{};
|
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]{};
|
||||||
SpacePacketCreator creator;
|
SpacePacketCreator creator;
|
||||||
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
|
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
|
||||||
@ -214,6 +223,7 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
|||||||
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
|
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
|
||||||
|
|
||||||
bool terminate = false;
|
bool terminate = false;
|
||||||
|
bool debugMode = false;
|
||||||
|
|
||||||
SimpleRingBuffer ringBuf;
|
SimpleRingBuffer ringBuf;
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user