Merge branch 'v4.0.0-dev' into extend-cp-helper
Some checks failed
EIVE/eive-obsw/pipeline/pr-v4.0.0-dev There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-v4.0.0-dev There was a failure building this commit
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <fsfw/filesystem/HasFileSystemIF.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw_hal/linux/uio/UioMapper.h>
|
||||
|
||||
#include "commonConfig.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
@ -22,6 +23,7 @@
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
||||
#include "bsp_q7s/boardconfig/busConf.h"
|
||||
#include "bsp_q7s/fs/SdCardManager.h"
|
||||
#include "bsp_q7s/memory/scratchApi.h"
|
||||
#include "bsp_q7s/xadc/Xadc.h"
|
||||
@ -112,6 +114,9 @@ void CoreController::performControlOperation() {
|
||||
sdStateMachine();
|
||||
performMountedSdCardOperations();
|
||||
readHkData();
|
||||
if (dumpContext.active) {
|
||||
dirListingDumpHandler();
|
||||
}
|
||||
|
||||
if (shellCmdIsExecuting) {
|
||||
bool replyReceived = false;
|
||||
@ -182,6 +187,14 @@ ReturnValue_t CoreController::initialize() {
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "Subscribing for GPS GPS_FIX_CHANGE event failed" << std::endl;
|
||||
}
|
||||
|
||||
UioMapper sysRomMapper(q7s::UIO_SYS_ROM);
|
||||
result = sysRomMapper.getMappedAdress(&mappedSysRomAddr, UioMapper::Permissions::READ_ONLY);
|
||||
if (result != returnvalue::OK) {
|
||||
// TODO: This might be a reason to switch to another image..
|
||||
sif::error << "Getting mapped SYS ROM UIO address failed" << std::endl;
|
||||
return ObjectManager::CHILD_INIT_FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
@ -220,6 +233,11 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
||||
}
|
||||
|
||||
triggerEvent(VERSION_INFO, p1, p2);
|
||||
if (mappedSysRomAddr != nullptr) {
|
||||
uint32_t p1Firmware = *(reinterpret_cast<uint32_t *>(mappedSysRomAddr));
|
||||
uint32_t p2Firmware = *(reinterpret_cast<uint32_t *>(mappedSysRomAddr) + 1);
|
||||
triggerEvent(FIRMWARE_INFO, p1Firmware, p2Firmware);
|
||||
}
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
case (ANNOUNCE_BOOT_COUNTS): {
|
||||
@ -1041,7 +1059,6 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
std::array<uint8_t, 1024> dirListingBuf{};
|
||||
dirListingBuf[8] = parser.compressionOptionSet();
|
||||
// First four bytes reserved for segment index. One byte for compression option information
|
||||
std::strcpy(reinterpret_cast<char *>(dirListingBuf.data() + 2 * sizeof(uint32_t) + 1), repoName);
|
||||
@ -1050,38 +1067,47 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::error_code e;
|
||||
size_t totalFileSize = std::filesystem::file_size(LIST_DIR_DUMP_WORK_FILE, e);
|
||||
uint32_t segmentIdx = 0;
|
||||
size_t dumpedBytes = 0;
|
||||
dumpContext.totalFileSize = std::filesystem::file_size(LIST_DIR_DUMP_WORK_FILE, e);
|
||||
dumpContext.segmentIdx = 0;
|
||||
dumpContext.dumpedBytes = 0;
|
||||
size_t nextDumpLen = 0;
|
||||
size_t dummy = 0;
|
||||
size_t maxDumpLen = dirListingBuf.size() - 2 * sizeof(uint32_t) - 1 - repoNameLen - 1;
|
||||
size_t listingDataOffset = 2 * sizeof(uint32_t) + 1 + repoNameLen + 1;
|
||||
uint32_t chunks = totalFileSize / maxDumpLen;
|
||||
if (totalFileSize % maxDumpLen != 0) {
|
||||
dumpContext.maxDumpLen = dirListingBuf.size() - 2 * sizeof(uint32_t) - 1 - repoNameLen - 1;
|
||||
dumpContext.listingDataOffset = 2 * sizeof(uint32_t) + 1 + repoNameLen + 1;
|
||||
uint32_t chunks = dumpContext.totalFileSize / dumpContext.maxDumpLen;
|
||||
if (dumpContext.totalFileSize % dumpContext.maxDumpLen != 0) {
|
||||
chunks++;
|
||||
}
|
||||
SerializeAdapter::serialize(&chunks, dirListingBuf.data() + sizeof(uint32_t), &dummy,
|
||||
dirListingBuf.size() - sizeof(uint32_t),
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
while (dumpedBytes < totalFileSize) {
|
||||
ifile.seekg(dumpedBytes, std::ios::beg);
|
||||
nextDumpLen = maxDumpLen;
|
||||
if (totalFileSize - dumpedBytes < maxDumpLen) {
|
||||
nextDumpLen = totalFileSize - dumpedBytes;
|
||||
while (dumpContext.dumpedBytes < dumpContext.totalFileSize) {
|
||||
ifile.seekg(dumpContext.dumpedBytes, std::ios::beg);
|
||||
nextDumpLen = dumpContext.maxDumpLen;
|
||||
if (dumpContext.totalFileSize - dumpContext.dumpedBytes < dumpContext.maxDumpLen) {
|
||||
nextDumpLen = dumpContext.totalFileSize - dumpContext.dumpedBytes;
|
||||
}
|
||||
SerializeAdapter::serialize(&segmentIdx, dirListingBuf.data(), &dummy, dirListingBuf.size(),
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
ifile.read(reinterpret_cast<char *>(dirListingBuf.data() + listingDataOffset), nextDumpLen);
|
||||
SerializeAdapter::serialize(&dumpContext.segmentIdx, dirListingBuf.data(), &dummy,
|
||||
dirListingBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||
ifile.read(reinterpret_cast<char *>(dirListingBuf.data() + dumpContext.listingDataOffset),
|
||||
nextDumpLen);
|
||||
result = actionHelper.reportData(commandedBy, actionId, dirListingBuf.data(),
|
||||
listingDataOffset + nextDumpLen);
|
||||
dumpContext.listingDataOffset + nextDumpLen);
|
||||
if (result != returnvalue::OK) {
|
||||
// Remove work file when we are done
|
||||
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
||||
return result;
|
||||
}
|
||||
segmentIdx++;
|
||||
dumpedBytes += nextDumpLen;
|
||||
dumpContext.segmentIdx++;
|
||||
dumpContext.dumpedBytes += nextDumpLen;
|
||||
// Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles.
|
||||
if (dumpContext.segmentIdx == 10) {
|
||||
dumpContext.active = true;
|
||||
dumpContext.firstDump = true;
|
||||
dumpContext.commander = commandedBy;
|
||||
dumpContext.actionId = actionId;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
}
|
||||
// Remove work file when we are done
|
||||
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
||||
@ -2349,6 +2375,54 @@ MessageQueueId_t CoreController::getCommandQueue() const {
|
||||
return ExtendedControllerBase::getCommandQueue();
|
||||
}
|
||||
|
||||
void CoreController::dirListingDumpHandler() {
|
||||
if (dumpContext.firstDump) {
|
||||
dumpContext.firstDump = false;
|
||||
return;
|
||||
}
|
||||
size_t nextDumpLen = 0;
|
||||
size_t dummy = 0;
|
||||
ReturnValue_t result;
|
||||
std::error_code e;
|
||||
std::ifstream ifile(LIST_DIR_DUMP_WORK_FILE, std::ios::binary);
|
||||
if (ifile.bad()) {
|
||||
return;
|
||||
}
|
||||
while (dumpContext.dumpedBytes < dumpContext.totalFileSize) {
|
||||
ifile.seekg(dumpContext.dumpedBytes, std::ios::beg);
|
||||
nextDumpLen = dumpContext.maxDumpLen;
|
||||
if (dumpContext.totalFileSize - dumpContext.dumpedBytes < dumpContext.maxDumpLen) {
|
||||
nextDumpLen = dumpContext.totalFileSize - dumpContext.dumpedBytes;
|
||||
}
|
||||
SerializeAdapter::serialize(&dumpContext.segmentIdx, dirListingBuf.data(), &dummy,
|
||||
dirListingBuf.size(), SerializeIF::Endianness::NETWORK);
|
||||
ifile.read(reinterpret_cast<char *>(dirListingBuf.data() + dumpContext.listingDataOffset),
|
||||
nextDumpLen);
|
||||
result =
|
||||
actionHelper.reportData(dumpContext.commander, dumpContext.actionId, dirListingBuf.data(),
|
||||
dumpContext.listingDataOffset + nextDumpLen);
|
||||
if (result != returnvalue::OK) {
|
||||
// Remove work file when we are done
|
||||
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
||||
dumpContext.active = false;
|
||||
actionHelper.finish(false, dumpContext.commander, dumpContext.actionId, result);
|
||||
return;
|
||||
}
|
||||
dumpContext.segmentIdx++;
|
||||
dumpContext.dumpedBytes += nextDumpLen;
|
||||
// Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles.
|
||||
if (dumpContext.segmentIdx == 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dumpContext.dumpedBytes >= dumpContext.totalFileSize) {
|
||||
actionHelper.finish(true, dumpContext.commander, dumpContext.actionId, result);
|
||||
dumpContext.active = false;
|
||||
// Remove work file when we are done
|
||||
std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e);
|
||||
}
|
||||
}
|
||||
|
||||
bool CoreController::isNumber(const std::string &s) {
|
||||
return !s.empty() && std::find_if(s.begin(), s.end(),
|
||||
[](unsigned char c) { return !std::isdigit(c); }) == s.end();
|
||||
|
Reference in New Issue
Block a user