v1.17.0 #327
@ -64,7 +64,7 @@ ReturnValue_t PlocSupervisorHandler::initialize() {
|
||||
if (result != returnvalue::OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
supvHelper->setComCookie(comCookie);
|
||||
// supvHelper->setComCookie(comCookie);
|
||||
|
||||
result = eventSubscription();
|
||||
if (result != returnvalue::OK) {
|
||||
@ -97,7 +97,7 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
|
||||
|
||||
switch (actionId) {
|
||||
case TERMINATE_SUPV_HELPER: {
|
||||
supvHelper->stopProcess();
|
||||
supvHelper->stop();
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
default:
|
||||
@ -148,18 +148,18 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
|
||||
plocSupvHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case LOGGING_REQUEST_EVENT_BUFFERS: {
|
||||
if (size > config::MAX_PATH_SIZE) {
|
||||
return result::FILENAME_TOO_LONG;
|
||||
}
|
||||
result = supvHelper->startEventBufferRequest(
|
||||
std::string(reinterpret_cast<const char*>(data), size));
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
plocSupvHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
// case LOGGING_REQUEST_EVENT_BUFFERS: {
|
||||
// if (size > config::MAX_PATH_SIZE) {
|
||||
// return result::FILENAME_TOO_LONG;
|
||||
// }
|
||||
// result = supvHelper->startEventBufferRequest(
|
||||
// std::string(reinterpret_cast<const char*>(data), size));
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
// plocSupvHelperExecuting = true;
|
||||
// return EXECUTION_FINISHED;
|
||||
// }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ ReturnValue_t PlocSupvHelper::setComIF(UartComIF* uartComIF_) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
|
||||
// void PlocSupvHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
|
||||
|
||||
ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
|
||||
uint32_t startAddress) {
|
||||
@ -182,6 +182,12 @@ ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performUpdate(const supv::UpdateParams& params) {
|
||||
lock->lockMutex();
|
||||
InternalState current = state;
|
||||
lock->unlockMutex();
|
||||
if (current != InternalState::DEFAULT) {
|
||||
return HasActionsIF::IS_BUSY;
|
||||
}
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
#ifdef XIPHOS_Q7S
|
||||
result = FilesystemHelper::checkPath(params.file);
|
||||
@ -204,6 +210,9 @@ ReturnValue_t PlocSupvHelper::performUpdate(const supv::UpdateParams& params) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
MutexGuard mg(lock);
|
||||
|
||||
update.file = params.file;
|
||||
update.fullFileSize = getFileSize(update.file);
|
||||
if (params.bytesWritten > update.fullFileSize) {
|
||||
@ -220,54 +229,74 @@ ReturnValue_t PlocSupvHelper::performUpdate(const supv::UpdateParams& params) {
|
||||
update.packetNum = 1;
|
||||
update.deleteMemory = params.deleteMemory;
|
||||
update.sequenceCount = params.seqCount;
|
||||
state = InternalState::LONGER_REQUEST;
|
||||
request = Request::UPDATE;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore->release();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performMemCheck(std::string file, uint8_t memoryId,
|
||||
uint32_t startAddress) {
|
||||
update.file = file;
|
||||
update.fullFileSize = getFileSize(file);
|
||||
return performMemCheck(memoryId, startAddress, getFileSize(update.file), true);
|
||||
lock->lockMutex();
|
||||
InternalState current = state;
|
||||
lock->unlockMutex();
|
||||
if (current != InternalState::DEFAULT) {
|
||||
return HasActionsIF::IS_BUSY;
|
||||
}
|
||||
return performMemCheck(file, memoryId, startAddress, getFileSize(update.file), true);
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::performMemCheck(uint8_t memoryId, uint32_t startAddress,
|
||||
size_t sizeToCheck, bool checkCrc) {
|
||||
ReturnValue_t PlocSupvHelper::performMemCheck(std::string file, uint8_t memoryId,
|
||||
uint32_t startAddress, size_t sizeToCheck,
|
||||
bool checkCrc) {
|
||||
{
|
||||
MutexGuard mg(lock);
|
||||
update.file = file;
|
||||
update.fullFileSize = getFileSize(file);
|
||||
state = InternalState::LONGER_REQUEST;
|
||||
request = Request::CHECK_MEMORY;
|
||||
update.memoryId = memoryId;
|
||||
update.startAddress = startAddress;
|
||||
update.length = sizeToCheck;
|
||||
update.crcShouldBeChecked = checkCrc;
|
||||
request = Request::CHECK_MEMORY;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore->release();
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::initiateUpdateContinuation() {
|
||||
ReturnValue_t PlocSupvHelper::initiateUpdateContinuation() {
|
||||
lock->lockMutex();
|
||||
InternalState current = state;
|
||||
lock->unlockMutex();
|
||||
if (current != InternalState::DEFAULT) {
|
||||
return HasActionsIF::IS_BUSY;
|
||||
}
|
||||
MutexGuard mg(lock);
|
||||
state = InternalState::LONGER_REQUEST;
|
||||
request = Request::CONTINUE_UPDATE;
|
||||
semaphore->release();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocSupvHelper::startEventBufferRequest(std::string path) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t result = FilesystemHelper::checkPath(path);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
if (not std::filesystem::exists(path)) {
|
||||
return PATH_NOT_EXISTS;
|
||||
}
|
||||
eventBufferReq.path = path;
|
||||
request = Request::REQUEST_EVENT_BUFFER;
|
||||
uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
semaphore->release();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::stopProcess() { terminate = true; }
|
||||
// ReturnValue_t PlocSupvHelper::startEventBufferRequest(std::string path) {
|
||||
//#ifdef XIPHOS_Q7S
|
||||
// ReturnValue_t result = FilesystemHelper::checkPath(path);
|
||||
// if (result != returnvalue::OK) {
|
||||
// return result;
|
||||
// }
|
||||
//#endif
|
||||
// if (not std::filesystem::exists(path)) {
|
||||
// return PATH_NOT_EXISTS;
|
||||
// }
|
||||
// eventBufferReq.path = path;
|
||||
// request = Request::REQUEST_EVENT_BUFFER;
|
||||
// //uartComIF->flushUartTxAndRxBuf(comCookie);
|
||||
// semaphore->release();
|
||||
// return returnvalue::OK;
|
||||
// }
|
||||
|
||||
void PlocSupvHelper::stop() {
|
||||
MutexGuard mg(lock);
|
||||
state = InternalState::GO_TO_SLEEP;
|
||||
}
|
||||
|
||||
void PlocSupvHelper::executeFullCheckMemoryCommand() {
|
||||
ReturnValue_t result;
|
||||
@ -356,11 +385,6 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
|
||||
uint16_t dataLength = 0;
|
||||
ccsds::SequenceFlags seqFlags;
|
||||
while (update.bytesWritten < update.fullFileSize) {
|
||||
if (terminate) {
|
||||
terminate = false;
|
||||
triggerEvent(TERMINATED_UPDATE_PROCEDURE);
|
||||
return PROCESS_TERMINATED;
|
||||
}
|
||||
size_t remainingSize = update.fullFileSize - update.bytesWritten;
|
||||
bool lastSegment = false;
|
||||
if (remainingSize > supv::WriteMemory::CHUNK_MAX) {
|
||||
@ -1031,5 +1055,8 @@ ReturnValue_t PlocSupvHelper::parseRecRingBufForHdlc(size_t& readSize) {
|
||||
|
||||
void PlocSupvHelper::performUartShutdown() {
|
||||
tcflush(serialPort, TCIOFLUSH);
|
||||
// Clear ring buffers
|
||||
recRingBuf.clear();
|
||||
ipcRingBuf.clear();
|
||||
state = InternalState::GO_TO_SLEEP;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
|
||||
ReturnValue_t setComIF(UartComIF* uartComfIF_);
|
||||
void setComCookie(CookieIF* comCookie_);
|
||||
// void setComCookie(CookieIF* comCookie_);
|
||||
|
||||
/**
|
||||
* @brief Starts update procedure
|
||||
@ -136,24 +136,24 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
||||
ReturnValue_t performUpdate(const supv::UpdateParams& params);
|
||||
ReturnValue_t startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress);
|
||||
|
||||
ReturnValue_t performMemCheck(uint8_t memoryId, uint32_t startAddress, size_t sizeToCheck,
|
||||
bool checkCrc);
|
||||
ReturnValue_t performMemCheck(std::string file, uint8_t memoryId, uint32_t startAddress,
|
||||
size_t sizeToCheck, bool checkCrc);
|
||||
ReturnValue_t performMemCheck(std::string file, uint8_t memoryId, uint32_t startAddress);
|
||||
|
||||
/**
|
||||
* @brief This initiate the continuation of a failed update.
|
||||
*/
|
||||
void initiateUpdateContinuation();
|
||||
ReturnValue_t initiateUpdateContinuation();
|
||||
|
||||
/**
|
||||
* @brief Calling this function will initiate the procedure to request the event buffer
|
||||
*/
|
||||
ReturnValue_t startEventBufferRequest(std::string path);
|
||||
// ReturnValue_t startEventBufferRequest(std::string path);
|
||||
|
||||
/**
|
||||
* @brief Can be used to interrupt a running data transfer.
|
||||
*/
|
||||
void stopProcess();
|
||||
void stop();
|
||||
|
||||
static uint32_t buildProgParams1(uint8_t percent, uint16_t seqCount);
|
||||
|
||||
@ -242,7 +242,6 @@ class PlocSupvHelper : public DeviceCommunicationIF,
|
||||
|
||||
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf{};
|
||||
|
||||
bool terminate = false;
|
||||
bool debugMode = false;
|
||||
/**
|
||||
* Communication interface responsible for data transactions between OBC and Supervisor.
|
||||
|
Loading…
x
Reference in New Issue
Block a user