get correct sd card
All checks were successful
EIVE/eive-obsw/pipeline/pr-dev-7.5.0 This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-dev-7.5.0 This commit looks good
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
#include "AcsController.h"
|
||||
|
||||
#include <fsfw/datapool/PoolReadGuard.h>
|
||||
#include <mission/acs/defs.h>
|
||||
#include <mission/config/torquer.h>
|
||||
|
||||
AcsController::AcsController(object_id_t objectId, bool enableHkSets)
|
||||
AcsController::AcsController(object_id_t objectId, bool enableHkSets, SdCardMountedIF &sdcMan)
|
||||
: ExtendedControllerBase(objectId),
|
||||
enableHkSets(enableHkSets),
|
||||
sdcMan(sdcMan),
|
||||
fusedRotationEstimation(&acsParameters),
|
||||
guidance(&acsParameters),
|
||||
safeCtrl(&acsParameters),
|
||||
@ -1040,8 +1037,11 @@ ReturnValue_t AcsController::updateTle(const uint8_t *line1, const uint8_t *line
|
||||
}
|
||||
|
||||
ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) {
|
||||
// ToDo: check which SD card is active via sdcMan
|
||||
std::string path = SD_0 + TLE_FILE;
|
||||
auto mntPrefix = sdcMan.getCurrentMountPrefix();
|
||||
if (mntPrefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::string path = mntPrefix + TLE_FILE;
|
||||
// Clear existing TLE from file
|
||||
std::ofstream tleFile(path.c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
if (tleFile.is_open()) {
|
||||
@ -1049,27 +1049,34 @@ ReturnValue_t AcsController::writeTleToFs(const uint8_t *tle) {
|
||||
tleFile << "\n";
|
||||
tleFile.write(reinterpret_cast<const char *>(tle + 69), 69);
|
||||
} else {
|
||||
// return error
|
||||
return WRITE_FILE_FAILED;
|
||||
}
|
||||
tleFile.close();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t AcsController::readTleFromFs(uint8_t *line1, uint8_t *line2) {
|
||||
// ToDo: check which SD card is active via sdcMan
|
||||
std::string path = SD_0 + TLE_FILE;
|
||||
// Read existing TLE from file
|
||||
std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in);
|
||||
if (tleFile.is_open()) {
|
||||
std::string tleLine1, tleLine2;
|
||||
getline(tleFile, tleLine1);
|
||||
std::memcpy(line1, tleLine1.c_str(), 69);
|
||||
getline(tleFile, tleLine2);
|
||||
std::memcpy(line2, tleLine2.c_str(), 69);
|
||||
} else {
|
||||
// return error
|
||||
auto mntPrefix = sdcMan.getCurrentMountPrefix();
|
||||
if (mntPrefix == nullptr or !sdcMan.isSdCardUsable(std::nullopt)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
std::string path = mntPrefix + TLE_FILE;
|
||||
std::error_code e;
|
||||
if (std::filesystem::exists(path, e)) {
|
||||
// Read existing TLE from file
|
||||
std::fstream tleFile = std::fstream(path.c_str(), std::fstream::in);
|
||||
if (tleFile.is_open()) {
|
||||
std::string tleLine1, tleLine2;
|
||||
getline(tleFile, tleLine1);
|
||||
std::memcpy(line1, tleLine1.c_str(), 69);
|
||||
getline(tleFile, tleLine2);
|
||||
std::memcpy(line2, tleLine2.c_str(), 69);
|
||||
} else {
|
||||
triggerEvent(acs::TLE_FILE_READ_FAILED);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
tleFile.close();
|
||||
}
|
||||
tleFile.close();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user