reading chip and copy works

This commit is contained in:
Robin Müller 2021-07-28 19:46:19 +02:00
parent fc769be789
commit 125593be21
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 17 additions and 14 deletions

View File

@ -22,17 +22,19 @@ CoreController::CoreController(object_id_t objectId):
ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
try { try {
result = sdCardInit(); result = initSdCard();
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::CoreController: SD card init failed" << std::endl; sif::warning << "CoreController::CoreController: SD card init failed" << std::endl;
} }
result = initBootCopy();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::CoreController: Boot copy init" << std::endl;
}
} }
catch(const std::filesystem::filesystem_error& e) { catch(const std::filesystem::filesystem_error& e) {
sif::error << "CoreController::CoreController: sdCardInit failed with exception " << sif::error << "CoreController::CoreController: Failed with exception " <<
e.what() << std::endl; e.what() << std::endl;
} }
initBootCopy();
} }
ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) {
@ -68,7 +70,7 @@ ReturnValue_t CoreController::checkModeCommand(Mode_t mode, Submode_t submode,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t CoreController::sdCardInit() { ReturnValue_t CoreController::initSdCard() {
#if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE #if Q7S_SD_CARD_CONFIG == Q7S_SD_NONE
sif::info << "No SD card initialization will be performed" << std::endl; sif::info << "No SD card initialization will be performed" << std::endl;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
@ -376,12 +378,15 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId,
} }
ReturnValue_t CoreController::initBootCopy() { ReturnValue_t CoreController::initBootCopy() {
// We could create this file even before the OBSW is started..
std::string fileName = "/tmp/curr_copy.txt"; std::string fileName = "/tmp/curr_copy.txt";
std::string cmd = "xsc_boot_copy > " + fileName; if(not std::filesystem::exists(fileName)) {
int result = std::system(cmd.c_str()); // Thils file is created by the systemd service eive-early-config so this should
if(result != 0) { // not happen normally
utility::handleSystemError(result, "CoreController::initBootCopy"); std::string cmd = "xsc_boot_copy > " + fileName;
int result = std::system(cmd.c_str());
if(result != 0) {
utility::handleSystemError(result, "CoreController::initBootCopy");
}
} }
std::ifstream file(fileName); std::ifstream file(fileName);
std::string line; std::string line;
@ -390,10 +395,8 @@ ReturnValue_t CoreController::initBootCopy() {
int value = 0; int value = 0;
iss >> value; iss >> value;
currentChip = static_cast<Chip>(value); currentChip = static_cast<Chip>(value);
sif::debug << "Current chip: " << currentChip << std::endl;
iss >> value; iss >> value;
currentCopy = static_cast<Copy>(value); currentCopy = static_cast<Copy>(value);
sif::debug << "Current chip: " << currentCopy << std::endl;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -55,14 +55,14 @@ private:
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode); uint32_t *msToReachTheMode);
ReturnValue_t sdCardInit(); ReturnValue_t initSdCard();
ReturnValue_t sdCardSetup(SdCardManager& sdcMan, SdCardManager::SdStatusPair& statusPair, ReturnValue_t sdCardSetup(SdCardManager& sdcMan, SdCardManager::SdStatusPair& statusPair,
sd::SdCard sdCard, sd::SdStatus status, std::string sdString); sd::SdCard sdCard, sd::SdStatus status, std::string sdString);
ReturnValue_t sdCardColdRedundantInit(SdCardManager* sdcMan, ReturnValue_t sdCardColdRedundantInit(SdCardManager* sdcMan,
SdCardManager::SdStatusPair& statusPair); SdCardManager::SdStatusPair& statusPair);
ReturnValue_t initVersionFile(); ReturnValue_t initVersionFile();
static ReturnValue_t initBootCopy(); ReturnValue_t initBootCopy();
ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t actionListDirectoryIntoFile(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t *data, size_t size); const uint8_t *data, size_t size);