From 4f6f12217c5cb714fea63ed383fdfbaa15ce166f Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 5 May 2023 10:58:57 +0200 Subject: [PATCH 001/172] fixed variances of ADIS sensors --- mission/controller/acs/AcsParameters.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index 9600ca7e..badc47af 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -781,9 +781,9 @@ class AcsParameters : public HasParametersIF { /* var = sigma^2, sigma = RND*sqrt(freq), following values are RND^2 and not var as freq is * assumed to be equal for the same class of sensors */ - float gyr02variance[3] = {pow(3.0e-3, 2), // RND_x = 3.0e-3 deg/s/sqrt(Hz) rms - pow(3.0e-3, 2), // RND_y = 3.0e-3 deg/s/sqrt(Hz) rms - pow(4.3e-3, 2)}; // RND_z = 4.3e-3 deg/s/sqrt(Hz) rms + float gyr02variance[3] = {pow(4.6e-3, 2), // RND_x = 3.0e-3 deg/s/sqrt(Hz) rms + pow(4.6e-3, 2), // RND_y = 3.0e-3 deg/s/sqrt(Hz) rms + pow(6.1e-3, 2)}; // RND_z = 4.3e-3 deg/s/sqrt(Hz) rms float gyr13variance[3] = {pow(11e-3, 2), pow(11e-3, 2), pow(11e-3, 2)}; uint8_t preferAdis = false; float gyrFilterWeight = 0.6; From e78d458f06b780b17d0bea8fe17fb1c3690504fa Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 5 May 2023 11:00:46 +0200 Subject: [PATCH 002/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..5449853f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. +- The variance for the ADIS GYRs now represents the used `-3` version and not the `-1` version # [v2.0.5] 2023-05-11 From 1166c66c8c049661be67a89529d6cebf3eff935e Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 19 Apr 2023 15:31:45 +0200 Subject: [PATCH 003/172] added config values for testing --- fsfw | 2 +- mission/acs/gyroAdisHelpers.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 5eb9ee8b..258f0d33 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5eb9ee8bc1e6f8640cbea46febd11e4b92241881 +Subproject commit 258f0d331329d67e13eec9d7f4053fd269e3f9b6 diff --git a/mission/acs/gyroAdisHelpers.h b/mission/acs/gyroAdisHelpers.h index 09f0aa1e..c8a28369 100644 --- a/mission/acs/gyroAdisHelpers.h +++ b/mission/acs/gyroAdisHelpers.h @@ -92,6 +92,9 @@ static constexpr size_t SENSOR_READOUT_SIZE = 20 + 2; static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA; static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG; +static constexpr uint16_t FILT_CTRL = 0x0000; +static constexpr uint16_t DEC_RATE = 0x0013; + enum GlobCmds : uint8_t { FACTORY_CALIBRATION = 0b0000'0010, SENSOR_SELF_TEST = 0b0000'0100, From e04313b9f30d1873a92ff56455a10e42d086801e Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 09:35:38 +0200 Subject: [PATCH 004/172] make Robin happy --- mission/controller/AcsController.cpp | 12 +++++++++--- mission/controller/acs/control/Detumble.cpp | 6 ++++-- mission/controller/acs/control/Detumble.h | 5 +++-- mission/controller/acs/control/SafeCtrl.cpp | 7 ++++--- mission/controller/acs/control/SafeCtrl.h | 6 +++--- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 0b49de04..c6089aa6 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -169,7 +169,7 @@ void AcsController::performSafe() { guidance.getTargetParamsSafe(sunTargetDir); double magMomMtq[3] = {0, 0, 0}, errAng = 0.0; - uint8_t safeCtrlStrat = safeCtrl.safeCtrlStrategy( + acs::SafeModeStrategy safeCtrlStrat = safeCtrl.safeCtrlStrategy( mgmDataProcessed.mgmVecTot.isValid(), not mekfInvalidFlag, gyrDataProcessed.gyrVecTot.isValid(), susDataProcessed.susVecTot.isValid(), acsParameters.safeModeControllerParameters.useMekf, @@ -205,6 +205,9 @@ void AcsController::performSafe() { case (acs::SafeModeStrategy::SAFECTRL_NO_SENSORS_FOR_CONTROL): safeCtrlFailure(0, 1); break; + default: + sif::error << "AcsController: Invalid safe mode strategy for performSafe" << std::endl; + break; } actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, @@ -259,7 +262,7 @@ void AcsController::performDetumble() { triggerEvent(acs::MEKF_RECOVERY); mekfInvalidFlag = false; } - uint8_t safeCtrlStrat = detumble.detumbleStrategy( + acs::SafeModeStrategy safeCtrlStrat = detumble.detumbleStrategy( mgmDataProcessed.mgmVecTot.isValid(), gyrDataProcessed.gyrVecTot.isValid(), mgmDataProcessed.mgmVecTotDerivative.isValid(), acsParameters.detumbleParameter.useFullDetumbleLaw); @@ -279,6 +282,9 @@ void AcsController::performDetumble() { case (acs::SafeModeStrategy::SAFECTRL_NO_SENSORS_FOR_CONTROL): safeCtrlFailure(0, 1); break; + default: + sif::error << "AcsController: Invalid safe mode strategy for performDetumble" << std::endl; + break; } actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, @@ -477,7 +483,7 @@ void AcsController::performPointingCtrl() { enableAntiStiction = acsParameters.inertialModeControllerParameters.enableAntiStiction; break; default: - sif::error << "AcsController: Invalid mode for performPointingCtrl"; + sif::error << "AcsController: Invalid mode for performPointingCtrl" << std::endl; break; } diff --git a/mission/controller/acs/control/Detumble.cpp b/mission/controller/acs/control/Detumble.cpp index 9ca20862..8f422ec1 100644 --- a/mission/controller/acs/control/Detumble.cpp +++ b/mission/controller/acs/control/Detumble.cpp @@ -7,8 +7,10 @@ Detumble::Detumble() {} Detumble::~Detumble() {} -uint8_t Detumble::detumbleStrategy(const bool magFieldValid, const bool satRotRateValid, - const bool magFieldRateValid, const bool useFullDetumbleLaw) { +acs::SafeModeStrategy Detumble::detumbleStrategy(const bool magFieldValid, + const bool satRotRateValid, + const bool magFieldRateValid, + const bool useFullDetumbleLaw) { if (not magFieldValid) { return acs::SafeModeStrategy::SAFECTRL_NO_MAG_FIELD_FOR_CONTROL; } else if (satRotRateValid and useFullDetumbleLaw) { diff --git a/mission/controller/acs/control/Detumble.h b/mission/controller/acs/control/Detumble.h index 4424896e..9fca77e6 100644 --- a/mission/controller/acs/control/Detumble.h +++ b/mission/controller/acs/control/Detumble.h @@ -11,8 +11,9 @@ class Detumble { Detumble(); virtual ~Detumble(); - uint8_t detumbleStrategy(const bool magFieldValid, const bool satRotRateValid, - const bool magFieldRateValid, const bool useFullDetumbleLaw); + acs::SafeModeStrategy detumbleStrategy(const bool magFieldValid, const bool satRotRateValid, + const bool magFieldRateValid, + const bool useFullDetumbleLaw); void bDotLawFull(const double *satRotRateB, const double *magFieldB, double *magMomB, double gain); diff --git a/mission/controller/acs/control/SafeCtrl.cpp b/mission/controller/acs/control/SafeCtrl.cpp index f0ebd5a0..43677ccf 100644 --- a/mission/controller/acs/control/SafeCtrl.cpp +++ b/mission/controller/acs/control/SafeCtrl.cpp @@ -9,9 +9,10 @@ SafeCtrl::SafeCtrl(AcsParameters *acsParameters_) { acsParameters = acsParameter SafeCtrl::~SafeCtrl() {} -uint8_t SafeCtrl::safeCtrlStrategy(const bool magFieldValid, const bool mekfValid, - const bool satRotRateValid, const bool sunDirValid, - const uint8_t mekfEnabled, const uint8_t dampingEnabled) { +acs::SafeModeStrategy SafeCtrl::safeCtrlStrategy(const bool magFieldValid, const bool mekfValid, + const bool satRotRateValid, const bool sunDirValid, + const uint8_t mekfEnabled, + const uint8_t dampingEnabled) { if (not magFieldValid) { return acs::SafeModeStrategy::SAFECTRL_NO_MAG_FIELD_FOR_CONTROL; } else if (mekfEnabled and mekfValid) { diff --git a/mission/controller/acs/control/SafeCtrl.h b/mission/controller/acs/control/SafeCtrl.h index 91625360..12f9ddb0 100644 --- a/mission/controller/acs/control/SafeCtrl.h +++ b/mission/controller/acs/control/SafeCtrl.h @@ -12,9 +12,9 @@ class SafeCtrl { SafeCtrl(AcsParameters *acsParameters_); virtual ~SafeCtrl(); - uint8_t safeCtrlStrategy(const bool magFieldValid, const bool mekfValid, - const bool satRotRateValid, const bool sunDirValid, - const uint8_t mekfEnabled, const uint8_t dampingEnabled); + acs::SafeModeStrategy safeCtrlStrategy(const bool magFieldValid, const bool mekfValid, + const bool satRotRateValid, const bool sunDirValid, + const uint8_t mekfEnabled, const uint8_t dampingEnabled); void safeMekf(const double *magFieldB, const double *satRotRateB, const double *sunDirModelI, const double *quatBI, const double *sunDirRefB, double *magMomB, From 0ff7e0f97aaa04f3bb54465f40e0d3f793784971 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 10:19:07 +0200 Subject: [PATCH 005/172] RW cmd fix and cleanup --- mission/controller/AcsController.cpp | 7 +++--- mission/controller/acs/ActuatorCmd.cpp | 34 ++++++++++++++------------ mission/controller/acs/ActuatorCmd.h | 21 ++++++++-------- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index c6089aa6..bd3bea5a 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -489,10 +489,9 @@ void AcsController::performPointingCtrl() { actuatorCmd.cmdSpeedToRws( sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, - sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, torqueRws, - cmdSpeedRws, acsParameters.onBoardParams.sampleTime, - acsParameters.rwHandlingParameters.maxRwSpeed, - acsParameters.rwHandlingParameters.inertiaWheel); + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, + acsParameters.onBoardParams.sampleTime, acsParameters.rwHandlingParameters.inertiaWheel, + acsParameters.rwHandlingParameters.maxRwSpeed, torqueRws, cmdSpeedRws); if (enableAntiStiction) { ptgCtrl.rwAntistiction(&sensorValues, cmdSpeedRws); } diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index d2fe2d65..17d195e8 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -5,8 +5,6 @@ #include #include -#include - #include "util/CholeskyDecomposition.h" #include "util/MathOperations.h" @@ -25,24 +23,30 @@ void ActuatorCmd::scalingTorqueRws(double *rwTrq, double maxTorque) { } } -void ActuatorCmd::cmdSpeedToRws(int32_t speedRw0, int32_t speedRw1, int32_t speedRw2, - int32_t speedRw3, const double *rwTorque, int32_t *rwCmdSpeed, - double sampleTime, int32_t maxRwSpeed, double inertiaWheel) { - using namespace Math; - - // Calculating the commanded speed in RPM for every reaction wheel +void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, + const int32_t speedRw2, const int32_t speedRw3, + const double sampleTime, const double inertiaWheel, + const int32_t maxRwSpeed, const double *rwTorque, + int32_t *rwCmdSpeed) { + // concentrate RW speed values (in 0.1 [RPM]) in vector int32_t speedRws[4] = {speedRw0, speedRw1, speedRw2, speedRw3}; + + // calculate required RW speed as sum of current RW speed and RW speed delta + // delta w_rw = delta t / I_RW * torque_RW [rad/s] double deltaSpeed[4] = {0, 0, 0, 0}; - double radToRpm = 60 / (2 * PI); // factor for conversion to RPM - // W_RW = Torque_RW / I_RW * delta t [rad/s] - double factor = sampleTime / inertiaWheel * radToRpm; - int32_t deltaSpeedInt[4] = {0, 0, 0, 0}; + const double factor = sampleTime / inertiaWheel * RAD_PER_SEC_TO_RPM * 10; VectorOperations::mulScalar(rwTorque, factor, deltaSpeed, 4); + + // convert double to int32 + int32_t deltaSpeedInt[4] = {0, 0, 0, 0}; for (int i = 0; i < 4; i++) { deltaSpeedInt[i] = std::round(deltaSpeed[i]); } + + // sum of current RW speed and RW speed delta VectorOperations::add(speedRws, deltaSpeedInt, rwCmdSpeed, 4); - VectorOperations::mulScalar(rwCmdSpeed, 10, rwCmdSpeed, 4); + + // crop values which would exceed the maximum possible RPM for (uint8_t i = 0; i < 4; i++) { if (rwCmdSpeed[i] > maxRwSpeed) { rwCmdSpeed[i] = maxRwSpeed; @@ -54,11 +58,11 @@ void ActuatorCmd::cmdSpeedToRws(int32_t speedRw0, int32_t speedRw1, int32_t spee void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, const double *inverseAlignment, double maxDipol) { - // Convert to actuator frame + // convert to actuator frame double dipolMomentActuatorDouble[3] = {0, 0, 0}; MatrixOperations::multiply(inverseAlignment, dipolMoment, dipolMomentActuatorDouble, 3, 3, 1); - // Scaling along largest element if dipol exceeds maximum + // scaling along largest element if dipole exceeds maximum uint8_t maxIdx = 0; VectorOperations::maxAbsValue(dipolMomentActuatorDouble, 3, &maxIdx); double maxAbsValue = abs(dipolMomentActuatorDouble[maxIdx]); diff --git a/mission/controller/acs/ActuatorCmd.h b/mission/controller/acs/ActuatorCmd.h index 5d5d47f3..2c9624a9 100644 --- a/mission/controller/acs/ActuatorCmd.h +++ b/mission/controller/acs/ActuatorCmd.h @@ -1,9 +1,8 @@ #ifndef ACTUATORCMD_H_ #define ACTUATORCMD_H_ -#include "MultiplicativeKalmanFilter.h" -#include "SensorProcessing.h" -#include "SensorValues.h" +#include + class ActuatorCmd { public: @@ -19,17 +18,16 @@ class ActuatorCmd { void scalingTorqueRws(double *rwTrq, double maxTorque); /* - * @brief: cmdSpeedToRws() will set the maximum possible torque for the reaction - * wheels, also will calculate the needed revolutions per minute for the RWs, which will be given - * as Input to the RWs - * @param: rwTrqIn given torque from pointing controller - * rwTrqNS Nullspace torque + * @brief: cmdSpeedToRws() Calculates the RPM for the reaction wheel configuration, + * given the required torque calculated by the controller. Will also scale down the RPM of the + * wheels if they exceed the maximum possible RPM + * @param: rwTrq given torque from pointing controller * rwCmdSpeed output revolutions per minute for every * reaction wheel */ - void cmdSpeedToRws(int32_t speedRw0, int32_t speedRw1, int32_t speedRw2, int32_t speedRw3, - const double *rwTorque, int32_t *rwCmdSpeed, double sampleTime, - int32_t maxRwSpeed, double inertiaWheel); + void cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, + const int32_t speedRw3, const double sampleTime, const double inertiaWheel, + const int32_t maxRwSpeed, const double *rwTorque, int32_t *rwCmdSpeed); /* * @brief: cmdDipolMtq() gives the commanded dipol moment for the magnetorques @@ -42,6 +40,7 @@ class ActuatorCmd { protected: private: + static constexpr double RAD_PER_SEC_TO_RPM = 60 / (2 * M_PI); }; #endif /* ACTUATORCMD_H_ */ From 6705ede2fc451c97004db0cef7c2ae29712e591e Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 10:33:43 +0200 Subject: [PATCH 006/172] englando too hard --- mission/controller/AcsController.cpp | 27 +++++++++++------------- mission/controller/AcsController.h | 2 +- mission/controller/acs/AcsParameters.cpp | 2 +- mission/controller/acs/AcsParameters.h | 2 +- mission/controller/acs/ActuatorCmd.cpp | 27 +++++++++++------------- mission/controller/acs/ActuatorCmd.h | 11 +++++----- 6 files changed, 33 insertions(+), 38 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index bd3bea5a..b4523f09 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -210,9 +210,8 @@ void AcsController::performSafe() { break; } - actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, - *acsParameters.magnetorquerParameter.inverseAlignment, - acsParameters.magnetorquerParameter.dipolMax); + actuatorCmd.cmdDipoleMtq(*acsParameters.magnetorquerParameter.inverseAlignment, + acsParameters.magnetorquerParameter.dipoleMax, magMomMtq, cmdDipoleMtqs); // detumble check and switch if (mekfData.satRotRateMekf.isValid() && acsParameters.safeModeControllerParameters.useMekf && @@ -234,8 +233,8 @@ void AcsController::performSafe() { } updateCtrlValData(errAng, safeCtrlStrat); - updateActuatorCmdData(cmdDipolMtqs); - commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + updateActuatorCmdData(cmdDipoleMtqs); + commandActuators(cmdDipoleMtqs[0], cmdDipoleMtqs[1], cmdDipoleMtqs[2], acsParameters.magnetorquerParameter.torqueDuration); } @@ -287,9 +286,8 @@ void AcsController::performDetumble() { break; } - actuatorCmd.cmdDipolMtq(magMomMtq, cmdDipolMtqs, - *acsParameters.magnetorquerParameter.inverseAlignment, - acsParameters.magnetorquerParameter.dipolMax); + actuatorCmd.cmdDipoleMtq(*acsParameters.magnetorquerParameter.inverseAlignment, + acsParameters.magnetorquerParameter.dipoleMax, magMomMtq, cmdDipoleMtqs); if (mekfData.satRotRateMekf.isValid() && VectorOperations::norm(mekfData.satRotRateMekf.value, 3) < @@ -310,8 +308,8 @@ void AcsController::performDetumble() { } disableCtrlValData(); - updateActuatorCmdData(cmdDipolMtqs); - commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + updateActuatorCmdData(cmdDipoleMtqs); + commandActuators(cmdDipoleMtqs[0], cmdDipoleMtqs[1], cmdDipoleMtqs[2], acsParameters.magnetorquerParameter.torqueDuration); } @@ -495,13 +493,12 @@ void AcsController::performPointingCtrl() { if (enableAntiStiction) { ptgCtrl.rwAntistiction(&sensorValues, cmdSpeedRws); } - actuatorCmd.cmdDipolMtq(mgtDpDes, cmdDipolMtqs, - *acsParameters.magnetorquerParameter.inverseAlignment, - acsParameters.magnetorquerParameter.dipolMax); + actuatorCmd.cmdDipoleMtq(*acsParameters.magnetorquerParameter.inverseAlignment, + acsParameters.magnetorquerParameter.dipoleMax, mgtDpDes, cmdDipoleMtqs); updateCtrlValData(targetQuat, errorQuat, errorAngle, targetSatRotRate); - updateActuatorCmdData(torqueRws, cmdSpeedRws, cmdDipolMtqs); - commandActuators(cmdDipolMtqs[0], cmdDipolMtqs[1], cmdDipolMtqs[2], + updateActuatorCmdData(torqueRws, cmdSpeedRws, cmdDipoleMtqs); + commandActuators(cmdDipoleMtqs[0], cmdDipoleMtqs[1], cmdDipoleMtqs[2], acsParameters.magnetorquerParameter.torqueDuration, cmdSpeedRws[0], cmdSpeedRws[1], cmdSpeedRws[2], cmdSpeedRws[3], acsParameters.rwHandlingParameters.rampTime); diff --git a/mission/controller/AcsController.h b/mission/controller/AcsController.h index 6ec26c57..0c8b94bb 100644 --- a/mission/controller/AcsController.h +++ b/mission/controller/AcsController.h @@ -69,7 +69,7 @@ class AcsController : public ExtendedControllerBase, public ReceivesParameterMes bool mekfLost = false; int32_t cmdSpeedRws[4] = {0, 0, 0, 0}; - int16_t cmdDipolMtqs[3] = {0, 0, 0}; + int16_t cmdDipoleMtqs[3] = {0, 0, 0}; #if OBSW_THREAD_TRACING == 1 uint32_t opCounter = 0; diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 03500cc3..0e127b20 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -690,7 +690,7 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->setMatrix(magnetorquerParameter.inverseAlignment); break; case 0x5: - parameterWrapper->set(magnetorquerParameter.dipolMax); + parameterWrapper->set(magnetorquerParameter.dipoleMax); break; case 0x6: parameterWrapper->set(magnetorquerParameter.torqueDuration); diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index 9600ca7e..dac33ec2 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -931,7 +931,7 @@ class AcsParameters : public HasParametersIF { double mtq2orientationMatrix[3][3] = {{0, 0, 1}, {0, 1, 0}, {-1, 0, 0}}; double alignmentMatrixMtq[3][3] = {{0, 0, -1}, {-1, 0, 0}, {0, 1, 0}}; double inverseAlignment[3][3] = {{0, -1, 0}, {0, 0, 1}, {-1, 0, 0}}; - double dipolMax = 0.2; // [Am^2] + double dipoleMax = 0.2; // [Am^2] uint16_t torqueDuration = 300; // [ms] } magnetorquerParameter; diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 17d195e8..27d566c0 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -5,9 +5,6 @@ #include #include -#include "util/CholeskyDecomposition.h" -#include "util/MathOperations.h" - ActuatorCmd::ActuatorCmd() {} ActuatorCmd::~ActuatorCmd() {} @@ -56,24 +53,24 @@ void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, } } -void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, - const double *inverseAlignment, double maxDipol) { +void ActuatorCmd::cmdDipoleMtq(const double *inverseAlignment, const double maxDipole, + const double *dipoleMoment, int16_t *dipoleMomentActuator) { // convert to actuator frame - double dipolMomentActuatorDouble[3] = {0, 0, 0}; - MatrixOperations::multiply(inverseAlignment, dipolMoment, dipolMomentActuatorDouble, 3, 3, + double dipoleMomentActuatorDouble[3] = {0, 0, 0}; + MatrixOperations::multiply(inverseAlignment, dipoleMoment, dipoleMomentActuatorDouble, 3, 3, 1); // scaling along largest element if dipole exceeds maximum uint8_t maxIdx = 0; - VectorOperations::maxAbsValue(dipolMomentActuatorDouble, 3, &maxIdx); - double maxAbsValue = abs(dipolMomentActuatorDouble[maxIdx]); - if (maxAbsValue > maxDipol) { - double scalingFactor = maxDipol / maxAbsValue; - VectorOperations::mulScalar(dipolMomentActuatorDouble, scalingFactor, - dipolMomentActuatorDouble, 3); + VectorOperations::maxAbsValue(dipoleMomentActuatorDouble, 3, &maxIdx); + double maxAbsValue = abs(dipoleMomentActuatorDouble[maxIdx]); + if (maxAbsValue > maxDipole) { + double scalingFactor = maxDipole / maxAbsValue; + VectorOperations::mulScalar(dipoleMomentActuatorDouble, scalingFactor, + dipoleMomentActuatorDouble, 3); } // scale dipole from 1 Am^2 to 1e^-4 Am^2 - VectorOperations::mulScalar(dipolMomentActuatorDouble, 1e4, dipolMomentActuatorDouble, 3); + VectorOperations::mulScalar(dipoleMomentActuatorDouble, 1e4, dipoleMomentActuatorDouble, 3); for (int i = 0; i < 3; i++) { - dipolMomentActuator[i] = std::round(dipolMomentActuatorDouble[i]); + dipoleMomentActuator[i] = std::round(dipoleMomentActuatorDouble[i]); } } diff --git a/mission/controller/acs/ActuatorCmd.h b/mission/controller/acs/ActuatorCmd.h index 2c9624a9..6a1b3dbb 100644 --- a/mission/controller/acs/ActuatorCmd.h +++ b/mission/controller/acs/ActuatorCmd.h @@ -30,13 +30,14 @@ class ActuatorCmd { const int32_t maxRwSpeed, const double *rwTorque, int32_t *rwCmdSpeed); /* - * @brief: cmdDipolMtq() gives the commanded dipol moment for the magnetorques + * @brief: cmdDipoleMtq() gives the commanded dipole moment for the + * magnetorquer * - * @param: dipolMoment given dipol moment in spacecraft frame - * dipolMomentActuator resulting dipol moment in actuator reference frame + * @param: dipoleMoment given dipole moment in spacecraft frame + * dipoleMomentActuator resulting dipole moment in actuator reference frame */ - void cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, - const double *inverseAlignment, double maxDipol); + void cmdDipoleMtq(const double *inverseAlignment, const double maxDipole, + const double *dipoleMoment, int16_t *dipoleMomentActuator); protected: private: From 4e428e635383cec95ec3d783064945c56cb00375 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 10:47:20 +0200 Subject: [PATCH 007/172] fixed antistiction logic --- mission/controller/acs/control/PtgCtrl.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 1b20efb9..98d3a0fa 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -169,15 +169,9 @@ void PtgCtrl::rwAntistiction(ACS::SensorValues *sensorValues, int32_t *rwCmdSpee if (rwCmdSpeeds[i] != 0) { if (rwCmdSpeeds[i] > -acsParameters->rwHandlingParameters.stictionSpeed && rwCmdSpeeds[i] < acsParameters->rwHandlingParameters.stictionSpeed) { - if (currRwSpeed[i] == 0) { - if (rwCmdSpeeds[i] > 0) { - rwCmdSpeeds[i] = acsParameters->rwHandlingParameters.stictionSpeed; - } else if (rwCmdSpeeds[i] < 0) { - rwCmdSpeeds[i] = -acsParameters->rwHandlingParameters.stictionSpeed; - } - } else if (currRwSpeed[i] < -acsParameters->rwHandlingParameters.stictionSpeed) { + if (rwCmdSpeeds[i] > currRwSpeed[i]) { rwCmdSpeeds[i] = acsParameters->rwHandlingParameters.stictionSpeed; - } else if (currRwSpeed[i] > acsParameters->rwHandlingParameters.stictionSpeed) { + } else if (rwCmdSpeeds[i] < currRwSpeed[i]) { rwCmdSpeeds[i] = -acsParameters->rwHandlingParameters.stictionSpeed; } } From a71be232acaf2e9ce2ebc893f5d5113b9be17242 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 11:21:02 +0200 Subject: [PATCH 008/172] make Robin even happier --- mission/controller/acs/control/PtgCtrl.cpp | 8 ++++---- mission/controller/acs/control/PtgCtrl.h | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 98d3a0fa..21d86e28 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -5,9 +5,7 @@ #include #include #include -#include - -#include "../util/MathOperations.h" +#include PtgCtrl::PtgCtrl(AcsParameters *acsParameters_) { acsParameters = acsParameters_; } @@ -135,7 +133,9 @@ void PtgCtrl::ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawP void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawParameters, const int32_t *speedRw0, const int32_t *speedRw1, const int32_t *speedRw2, const int32_t *speedRw3, double *rwTrqNs) { - double speedRws[4] = {(double)*speedRw0, (double)*speedRw1, (double)*speedRw2, (double)*speedRw3}; + // concentrate RW speeds as vector and convert to double + double speedRws[4] = {static_cast(*speedRw0), static_cast(*speedRw1), + static_cast(*speedRw2), static_cast(*speedRw3)}; double wheelMomentum[4] = {0, 0, 0, 0}; double rpmOffset[4] = {1, 1, 1, -1}, factor = 350 * 2 * Math::PI / 60; // conversion to [rad/s] for further calculations diff --git a/mission/controller/acs/control/PtgCtrl.h b/mission/controller/acs/control/PtgCtrl.h index fad72e6b..870732c7 100644 --- a/mission/controller/acs/control/PtgCtrl.h +++ b/mission/controller/acs/control/PtgCtrl.h @@ -1,13 +1,10 @@ #ifndef PTGCTRL_H_ #define PTGCTRL_H_ +#include +#include +#include #include -#include -#include - -#include "../AcsParameters.h" -#include "../SensorValues.h" -#include "eive/resultClassIds.h" class PtgCtrl { /* @@ -45,6 +42,7 @@ class PtgCtrl { private: const AcsParameters *acsParameters; + static constexpr double RAD_PER_SEC_TO_RPM = 60 / (2 * M_PI); }; #endif /* ACS_CONTROL_PTGCTRL_H_ */ From 5a9da1a99ca47dae2de07e2b76443b3a00af4647 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 13:52:41 +0200 Subject: [PATCH 009/172] fixed nullspace controller --- mission/controller/acs/AcsParameters.cpp | 87 +++++++++++++--------- mission/controller/acs/AcsParameters.h | 4 +- mission/controller/acs/control/PtgCtrl.cpp | 34 +++++---- mission/controller/acs/control/PtgCtrl.h | 2 +- 4 files changed, 74 insertions(+), 53 deletions(-) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 0e127b20..e9ab50f3 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -315,7 +315,7 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->setMatrix(rwMatrices.without4); break; case 0x6: - parameterWrapper->setVector(rwMatrices.nullspace); + parameterWrapper->setVector(rwMatrices.nullspaceVector); break; default: return INVALID_IDENTIFIER_ID; @@ -375,15 +375,18 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->set(idleModeControllerParameters.gainNullspace); break; case 0x5: - parameterWrapper->setVector(idleModeControllerParameters.desatMomentumRef); + parameterWrapper->set(idleModeControllerParameters.nullspaceSpeed); break; case 0x6: - parameterWrapper->set(idleModeControllerParameters.deSatGainFactor); + parameterWrapper->setVector(idleModeControllerParameters.desatMomentumRef); break; case 0x7: - parameterWrapper->set(idleModeControllerParameters.desatOn); + parameterWrapper->set(idleModeControllerParameters.deSatGainFactor); break; case 0x8: + parameterWrapper->set(idleModeControllerParameters.desatOn); + break; + case 0x9: parameterWrapper->set(idleModeControllerParameters.enableAntiStiction); break; default: @@ -408,48 +411,51 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->set(targetModeControllerParameters.gainNullspace); break; case 0x5: - parameterWrapper->setVector(targetModeControllerParameters.desatMomentumRef); + parameterWrapper->set(targetModeControllerParameters.nullspaceSpeed); break; case 0x6: - parameterWrapper->set(targetModeControllerParameters.deSatGainFactor); + parameterWrapper->setVector(targetModeControllerParameters.desatMomentumRef); break; case 0x7: - parameterWrapper->set(targetModeControllerParameters.desatOn); + parameterWrapper->set(targetModeControllerParameters.deSatGainFactor); break; case 0x8: - parameterWrapper->set(targetModeControllerParameters.enableAntiStiction); + parameterWrapper->set(targetModeControllerParameters.desatOn); break; case 0x9: - parameterWrapper->setVector(targetModeControllerParameters.refDirection); + parameterWrapper->set(targetModeControllerParameters.enableAntiStiction); break; case 0xA: - parameterWrapper->setVector(targetModeControllerParameters.refRotRate); + parameterWrapper->setVector(targetModeControllerParameters.refDirection); break; case 0xB: - parameterWrapper->setVector(targetModeControllerParameters.quatRef); + parameterWrapper->setVector(targetModeControllerParameters.refRotRate); break; case 0xC: - parameterWrapper->set(targetModeControllerParameters.timeElapsedMax); + parameterWrapper->setVector(targetModeControllerParameters.quatRef); break; case 0xD: - parameterWrapper->set(targetModeControllerParameters.latitudeTgt); + parameterWrapper->set(targetModeControllerParameters.timeElapsedMax); break; case 0xE: - parameterWrapper->set(targetModeControllerParameters.longitudeTgt); + parameterWrapper->set(targetModeControllerParameters.latitudeTgt); break; case 0xF: - parameterWrapper->set(targetModeControllerParameters.altitudeTgt); + parameterWrapper->set(targetModeControllerParameters.longitudeTgt); break; case 0x10: - parameterWrapper->set(targetModeControllerParameters.avoidBlindStr); + parameterWrapper->set(targetModeControllerParameters.altitudeTgt); break; case 0x11: - parameterWrapper->set(targetModeControllerParameters.blindAvoidStart); + parameterWrapper->set(targetModeControllerParameters.avoidBlindStr); break; case 0x12: - parameterWrapper->set(targetModeControllerParameters.blindAvoidStop); + parameterWrapper->set(targetModeControllerParameters.blindAvoidStart); break; case 0x13: + parameterWrapper->set(targetModeControllerParameters.blindAvoidStop); + break; + case 0x14: parameterWrapper->set(targetModeControllerParameters.blindRotRate); break; default: @@ -474,30 +480,33 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->set(gsTargetModeControllerParameters.gainNullspace); break; case 0x5: - parameterWrapper->setVector(gsTargetModeControllerParameters.desatMomentumRef); + parameterWrapper->set(gsTargetModeControllerParameters.nullspaceSpeed); break; case 0x6: - parameterWrapper->set(gsTargetModeControllerParameters.deSatGainFactor); + parameterWrapper->setVector(gsTargetModeControllerParameters.desatMomentumRef); break; case 0x7: - parameterWrapper->set(gsTargetModeControllerParameters.desatOn); + parameterWrapper->set(gsTargetModeControllerParameters.deSatGainFactor); break; case 0x8: - parameterWrapper->set(gsTargetModeControllerParameters.enableAntiStiction); + parameterWrapper->set(gsTargetModeControllerParameters.desatOn); break; case 0x9: - parameterWrapper->setVector(gsTargetModeControllerParameters.refDirection); + parameterWrapper->set(gsTargetModeControllerParameters.enableAntiStiction); break; case 0xA: - parameterWrapper->set(gsTargetModeControllerParameters.timeElapsedMax); + parameterWrapper->setVector(gsTargetModeControllerParameters.refDirection); break; case 0xB: - parameterWrapper->set(gsTargetModeControllerParameters.latitudeTgt); + parameterWrapper->set(gsTargetModeControllerParameters.timeElapsedMax); break; case 0xC: - parameterWrapper->set(gsTargetModeControllerParameters.longitudeTgt); + parameterWrapper->set(gsTargetModeControllerParameters.latitudeTgt); break; case 0xD: + parameterWrapper->set(gsTargetModeControllerParameters.longitudeTgt); + break; + case 0xE: parameterWrapper->set(gsTargetModeControllerParameters.altitudeTgt); break; default: @@ -522,21 +531,24 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->set(nadirModeControllerParameters.gainNullspace); break; case 0x5: - parameterWrapper->setVector(nadirModeControllerParameters.desatMomentumRef); + parameterWrapper->set(nadirModeControllerParameters.nullspaceSpeed); break; case 0x6: - parameterWrapper->set(nadirModeControllerParameters.deSatGainFactor); + parameterWrapper->setVector(nadirModeControllerParameters.desatMomentumRef); break; case 0x7: - parameterWrapper->set(nadirModeControllerParameters.desatOn); + parameterWrapper->set(nadirModeControllerParameters.deSatGainFactor); break; case 0x8: - parameterWrapper->set(nadirModeControllerParameters.enableAntiStiction); + parameterWrapper->set(nadirModeControllerParameters.desatOn); break; case 0x9: - parameterWrapper->setVector(nadirModeControllerParameters.refDirection); + parameterWrapper->set(nadirModeControllerParameters.enableAntiStiction); break; case 0xA: + parameterWrapper->setVector(nadirModeControllerParameters.refDirection); + break; + case 0xB: parameterWrapper->setVector(nadirModeControllerParameters.quatRef); break; case 0xC: @@ -564,21 +576,24 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->set(inertialModeControllerParameters.gainNullspace); break; case 0x5: - parameterWrapper->setVector(inertialModeControllerParameters.desatMomentumRef); + parameterWrapper->set(inertialModeControllerParameters.nullspaceSpeed); break; case 0x6: - parameterWrapper->set(inertialModeControllerParameters.deSatGainFactor); + parameterWrapper->setVector(inertialModeControllerParameters.desatMomentumRef); break; case 0x7: - parameterWrapper->set(inertialModeControllerParameters.desatOn); + parameterWrapper->set(inertialModeControllerParameters.deSatGainFactor); break; case 0x8: - parameterWrapper->set(inertialModeControllerParameters.enableAntiStiction); + parameterWrapper->set(inertialModeControllerParameters.desatOn); break; case 0x9: - parameterWrapper->setVector(inertialModeControllerParameters.tgtQuat); + parameterWrapper->set(inertialModeControllerParameters.enableAntiStiction); break; case 0xA: + parameterWrapper->setVector(inertialModeControllerParameters.tgtQuat); + break; + case 0xB: parameterWrapper->setVector(inertialModeControllerParameters.refRotRate); break; case 0xC: diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index dac33ec2..2e428e4b 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -814,7 +814,7 @@ class AcsParameters : public HasParametersIF { {1.0864, 0, 0}, {-0.5432, -0.5432, 1.2797}, {0, 0, 0}, {-0.5432, 0.5432, 1.2797}}; double without4[4][3] = { {0.5432, 0.5432, 1.2797}, {0, -1.0864, 0}, {-0.5432, 0.5432, 1.2797}, {0, 0, 0}}; - double nullspace[4] = {-0.5000, 0.5000, -0.5000, 0.5000}; + double nullspaceVector[4] = {-1, 1, -1, 1}; } rwMatrices; struct SafeModeControllerParameters { @@ -838,7 +838,9 @@ class AcsParameters : public HasParametersIF { double om = 0.3; double omMax = 1 * M_PI / 180; double qiMin = 0.1; + double gainNullspace = 0.01; + double nullspaceSpeed = 32500; // 0.1 RPM double desatMomentumRef[3] = {0, 0, 0}; double deSatGainFactor = 1000; diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 21d86e28..0889d8c1 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -136,23 +136,27 @@ void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawPara // concentrate RW speeds as vector and convert to double double speedRws[4] = {static_cast(*speedRw0), static_cast(*speedRw1), static_cast(*speedRw2), static_cast(*speedRw3)}; - double wheelMomentum[4] = {0, 0, 0, 0}; - double rpmOffset[4] = {1, 1, 1, -1}, factor = 350 * 2 * Math::PI / 60; - // conversion to [rad/s] for further calculations - VectorOperations::mulScalar(rpmOffset, factor, rpmOffset, 4); - VectorOperations::mulScalar(speedRws, 2 * Math::PI / 60, speedRws, 4); - double diffRwSpeed[4] = {0, 0, 0, 0}; + + // calculate RPM offset utilizing the nullspace + double rpmOffset[4] = {0, 0, 0, 0}; + double rpmOffsetSpeed = pointingLawParameters->nullspaceSpeed / 10 * RPM_TO_RAD_PER_SEC; + VectorOperations::mulScalar(acsParameters->rwMatrices.nullspaceVector, rpmOffsetSpeed, + rpmOffset, 4); + + // calculate resulting angular momentum + double rwAngMomentum[4] = {0, 0, 0, 0}, diffRwSpeed[4] = {0, 0, 0, 0}; VectorOperations::subtract(speedRws, rpmOffset, diffRwSpeed, 4); VectorOperations::mulScalar(diffRwSpeed, acsParameters->rwHandlingParameters.inertiaWheel, - wheelMomentum, 4); - double gainNs = pointingLawParameters->gainNullspace; - double nullSpaceMatrix[4][4] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; - MathOperations::vecTransposeVecMatrix(acsParameters->rwMatrices.nullspace, - acsParameters->rwMatrices.nullspace, - *nullSpaceMatrix, 4); - MatrixOperations::multiply(*nullSpaceMatrix, wheelMomentum, rwTrqNs, 4, 4, 1); - VectorOperations::mulScalar(rwTrqNs, gainNs, rwTrqNs, 4); - VectorOperations::mulScalar(rwTrqNs, -1, rwTrqNs, 4); + rwAngMomentum, 4); + + // calculate resulting torque + double nullspaceMatrix[4][4] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + MatrixOperations::multiply(acsParameters->rwMatrices.nullspaceVector, + acsParameters->rwMatrices.nullspaceVector, *nullspaceMatrix, 4, + 1, 4); + MatrixOperations::multiply(*nullspaceMatrix, rwAngMomentum, rwTrqNs, 4, 4, 1); + VectorOperations::mulScalar(rwTrqNs, -1 * pointingLawParameters->gainNullspace, rwTrqNs, + 4); } void PtgCtrl::rwAntistiction(ACS::SensorValues *sensorValues, int32_t *rwCmdSpeeds) { diff --git a/mission/controller/acs/control/PtgCtrl.h b/mission/controller/acs/control/PtgCtrl.h index 870732c7..bb286d67 100644 --- a/mission/controller/acs/control/PtgCtrl.h +++ b/mission/controller/acs/control/PtgCtrl.h @@ -42,7 +42,7 @@ class PtgCtrl { private: const AcsParameters *acsParameters; - static constexpr double RAD_PER_SEC_TO_RPM = 60 / (2 * M_PI); + static constexpr double RPM_TO_RAD_PER_SEC = (2 * M_PI) / 60; }; #endif /* ACS_CONTROL_PTGCTRL_H_ */ From db63757c0c1f49ea022490f2b158f94f398b03e0 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 27 Apr 2023 15:40:15 +0200 Subject: [PATCH 010/172] deprecated include --- mission/controller/acs/control/PtgCtrl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 0889d8c1..56aa7615 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -5,7 +5,6 @@ #include #include #include -#include PtgCtrl::PtgCtrl(AcsParameters *acsParameters_) { acsParameters = acsParameters_; } From 722a4208d4b205e5e2afb4fe713f29e03a6e9bce Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:22:21 +0200 Subject: [PATCH 011/172] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..acfd8ef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,11 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. +- The dual lane assembly transition failed handler started new transitions towards the current mode + instead of the target mode. This means that if the dual lane assembly never reached the initial + submode (e.g. mode normal and submode dual side), it will transition back to the current mode, + which is `MODE_OFF`. Furthermore, this lead to invalid internal states, so the subsequent + recovery handling becomes stuck in the custom recovery sequence when swichting power back on. # [v2.0.5] 2023-05-11 From 65c59352e9509e34732803f4a1c5245d6c7ab3bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:23:21 +0200 Subject: [PATCH 012/172] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acfd8ef3..c185fab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ will consitute of a breaking change warranting a new major release: - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, - which is `MODE_OFF`. Furthermore, this lead to invalid internal states, so the subsequent + which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent recovery handling becomes stuck in the custom recovery sequence when swichting power back on. # [v2.0.5] 2023-05-11 From db3dc807565b044325fbb845da4605a69f976e89 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:28:05 +0200 Subject: [PATCH 013/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c185fab1..af09ec1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ will consitute of a breaking change warranting a new major release: submode (e.g. mode normal and submode dual side), it will transition back to the current mode, which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent recovery handling becomes stuck in the custom recovery sequence when swichting power back on. +- The dual lane custom recovery handling was adapted to always perform proper power switch handling + irrespective of current or target modes. # [v2.0.5] 2023-05-11 From ad32eee70a0059981417255eab28ab8d7c341f15 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 15:34:45 +0200 Subject: [PATCH 014/172] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af09ec1a..7d096ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,9 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. + +# [v2.0.5] to be released + - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, From 52acb3373edb1af0b2ad4913ffe0111f0ca55938 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:07:54 +0200 Subject: [PATCH 015/172] changelog --- CHANGELOG.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d096ddd..dc320982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,16 +47,6 @@ will consitute of a breaking change warranting a new major release: - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. -# [v2.0.5] to be released - -- The dual lane assembly transition failed handler started new transitions towards the current mode - instead of the target mode. This means that if the dual lane assembly never reached the initial - submode (e.g. mode normal and submode dual side), it will transition back to the current mode, - which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent - recovery handling becomes stuck in the custom recovery sequence when swichting power back on. -- The dual lane custom recovery handling was adapted to always perform proper power switch handling - irrespective of current or target modes. - # [v2.0.5] 2023-05-11 - The dual lane assembly transition failed handler started new transitions towards the current mode From 83a373859d0637ed809b8e466f9de3831229c79d Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 2 May 2023 09:40:48 +0200 Subject: [PATCH 016/172] Robin must be the happiest man alive --- mission/controller/acs/control/PtgCtrl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 56aa7615..6039d525 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -106,8 +106,11 @@ void PtgCtrl::ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawP return; } + // concentrate RW speeds as vector and convert to double + double speedRws[4] = {static_cast(*speedRw0), static_cast(*speedRw1), + static_cast(*speedRw2), static_cast(*speedRw3)}; + // calculating momentum of satellite and momentum of reaction wheels - double speedRws[4] = {(double)*speedRw0, (double)*speedRw1, (double)*speedRw2, (double)*speedRw3}; double momentumRwU[4] = {0, 0, 0, 0}, momentumRw[3] = {0, 0, 0}; VectorOperations::mulScalar(speedRws, acsParameters->rwHandlingParameters.inertiaWheel, momentumRwU, 4); From 8bb97f5f44cef56f1aef365faca0b9a508f228cd Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 3 May 2023 09:35:46 +0200 Subject: [PATCH 017/172] further fixes and cleanup for desaturation --- mission/controller/acs/control/PtgCtrl.cpp | 92 +++++++++++++--------- mission/controller/acs/control/PtgCtrl.h | 10 +-- 2 files changed, 60 insertions(+), 42 deletions(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 6039d525..c2c6e2b0 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -95,43 +95,6 @@ void PtgCtrl::ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters VectorOperations::mulScalar(torqueRws, -1, torqueRws, 4); } -void PtgCtrl::ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawParameters, - double *magFieldEst, bool magFieldEstValid, double *satRate, - int32_t *speedRw0, int32_t *speedRw1, int32_t *speedRw2, - int32_t *speedRw3, double *mgtDpDes) { - if (!(magFieldEstValid) || !(pointingLawParameters->desatOn)) { - mgtDpDes[0] = 0; - mgtDpDes[1] = 0; - mgtDpDes[2] = 0; - return; - } - - // concentrate RW speeds as vector and convert to double - double speedRws[4] = {static_cast(*speedRw0), static_cast(*speedRw1), - static_cast(*speedRw2), static_cast(*speedRw3)}; - - // calculating momentum of satellite and momentum of reaction wheels - double momentumRwU[4] = {0, 0, 0, 0}, momentumRw[3] = {0, 0, 0}; - VectorOperations::mulScalar(speedRws, acsParameters->rwHandlingParameters.inertiaWheel, - momentumRwU, 4); - MatrixOperations::multiply(*(acsParameters->rwMatrices.alignmentMatrix), momentumRwU, - momentumRw, 3, 4, 1); - double momentumSat[3] = {0, 0, 0}, momentumTotal[3] = {0, 0, 0}; - MatrixOperations::multiply(*(acsParameters->inertiaEIVE.inertiaMatrixDeployed), satRate, - momentumSat, 3, 3, 1); - VectorOperations::add(momentumSat, momentumRw, momentumTotal, 3); - // calculating momentum error - double deltaMomentum[3] = {0, 0, 0}; - VectorOperations::subtract(momentumTotal, pointingLawParameters->desatMomentumRef, - deltaMomentum, 3); - // resulting magnetic dipole command - double crossMomentumMagField[3] = {0, 0, 0}; - VectorOperations::cross(deltaMomentum, magFieldEst, crossMomentumMagField); - double normMag = VectorOperations::norm(magFieldEst, 3), factor = 0; - factor = (pointingLawParameters->deSatGainFactor) / normMag; - VectorOperations::mulScalar(crossMomentumMagField, factor, mgtDpDes, 3); -} - void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawParameters, const int32_t *speedRw0, const int32_t *speedRw1, const int32_t *speedRw2, const int32_t *speedRw3, double *rwTrqNs) { @@ -161,6 +124,61 @@ void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawPara 4); } +void PtgCtrl::ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawParameters, + const double *magFieldB, const bool magFieldBValid, + const double *satRate, const int32_t speedRw0, const int32_t speedRw1, + const int32_t speedRw2, const int32_t speedRw3, double *mgtDpDes) { + if (not magFieldBValid or not pointingLawParameters->desatOn) { + return; + } + + // concentrate RW speeds as vector and convert to double + double speedRws[4] = {static_cast(speedRw0), static_cast(speedRw1), + static_cast(speedRw2), static_cast(speedRw3)}; + + // convert magFieldB from uT to T + double magFieldBT[3] = {0, 0, 0}; + VectorOperations::mulScalar(magFieldB, 1e-6, magFieldBT, 3); + + // calculate angular momentum of the satellite + double angMomentumSat[3] = {0, 0, 0}; + MatrixOperations::multiply(*(acsParameters->inertiaEIVE.inertiaMatrixDeployed), satRate, + angMomentumSat, 3, 3, 1); + + // calculate angular momentum of the reaction wheels with respect to the nullspace RW speed + // relocate RW speed zero to nullspace RW speed + double refSpeedRws[4] = {0, 0, 0, 0}; + VectorOperations::mulScalar(acsParameters->rwMatrices.nullspaceVector, + pointingLawParameters->nullspaceSpeed, refSpeedRws, 4); + VectorOperations::subtract(speedRws, refSpeedRws, speedRws, 4); + // convert to rad/s + VectorOperations::mulScalar(speedRws, RPM_TO_RAD_PER_SEC, speedRws, 4); + // calculate angular momentum of each RW + double angMomentumRwU[4] = {0, 0, 0, 0}; + VectorOperations::mulScalar(speedRws, acsParameters->rwHandlingParameters.inertiaWheel, + angMomentumRwU, 4); + // convert RW angular momentum to body RF + double angMomentumRw[3] = {0, 0, 0}; + MatrixOperations::multiply(*(acsParameters->rwMatrices.alignmentMatrix), angMomentumRwU, + angMomentumRw, 3, 4, 1); + + // calculate total angular momentum + double angMomentumTotal[3] = {0, 0, 0}; + VectorOperations::add(angMomentumSat, angMomentumRw, angMomentumTotal, 3); + + // calculating momentum error + double deltaAngMomentum[3] = {0, 0, 0}; + VectorOperations::subtract(angMomentumTotal, pointingLawParameters->desatMomentumRef, + deltaAngMomentum, 3); + + // resulting magnetic dipole command + double crossAngMomentumMagField[3] = {0, 0, 0}; + VectorOperations::cross(deltaAngMomentum, magFieldBT, crossAngMomentumMagField); + double factor = + pointingLawParameters->deSatGainFactor / VectorOperations::norm(magFieldBT, 3); + VectorOperations::mulScalar(crossAngMomentumMagField, factor, mgtDpDes, 3); +} + void PtgCtrl::rwAntistiction(ACS::SensorValues *sensorValues, int32_t *rwCmdSpeeds) { bool rwAvailable[4] = { (sensorValues->rw1Set.state.value && sensorValues->rw1Set.state.isValid()), diff --git a/mission/controller/acs/control/PtgCtrl.h b/mission/controller/acs/control/PtgCtrl.h index bb286d67..f04950f9 100644 --- a/mission/controller/acs/control/PtgCtrl.h +++ b/mission/controller/acs/control/PtgCtrl.h @@ -26,15 +26,15 @@ class PtgCtrl { void ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters, const double *qError, const double *deltaRate, const double *rwPseudoInv, double *torqueRws); - void ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawParameters, - double *magFieldEst, bool magFieldEstValid, double *satRate, - int32_t *speedRw0, int32_t *speedRw1, int32_t *speedRw2, int32_t *speedRw3, - double *mgtDpDes); - void ptgNullspace(AcsParameters::PointingLawParameters *pointingLawParameters, const int32_t *speedRw0, const int32_t *speedRw1, const int32_t *speedRw2, const int32_t *speedRw3, double *rwTrqNs); + void ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawParameters, + const double *magFieldB, const bool magFieldBValid, const double *satRate, + const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, + const int32_t speedRw3, double *mgtDpDes); + /* @brief: Commands the stiction torque in case wheel speed is to low * torqueCommand modified torque after antistiction */ From e3dc39a028c30330feec2da043db5a919cb8369f Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 3 May 2023 09:40:00 +0200 Subject: [PATCH 018/172] fixes for function calls --- mission/controller/AcsController.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index b4523f09..f3ed5cda 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -384,8 +384,8 @@ void AcsController::performPointingCtrl() { ptgCtrl.ptgDesaturation( &acsParameters.idleModeControllerParameters, mgmDataProcessed.mgmVecTot.value, mgmDataProcessed.mgmVecTot.isValid(), mekfData.satRotRateMekf.value, - &(sensorValues.rw1Set.currSpeed.value), &(sensorValues.rw2Set.currSpeed.value), - &(sensorValues.rw3Set.currSpeed.value), &(sensorValues.rw4Set.currSpeed.value), mgtDpDes); + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, mgtDpDes); enableAntiStiction = acsParameters.idleModeControllerParameters.enableAntiStiction; break; @@ -408,8 +408,8 @@ void AcsController::performPointingCtrl() { ptgCtrl.ptgDesaturation( &acsParameters.targetModeControllerParameters, mgmDataProcessed.mgmVecTot.value, mgmDataProcessed.mgmVecTot.isValid(), mekfData.satRotRateMekf.value, - &(sensorValues.rw1Set.currSpeed.value), &(sensorValues.rw2Set.currSpeed.value), - &(sensorValues.rw3Set.currSpeed.value), &(sensorValues.rw4Set.currSpeed.value), mgtDpDes); + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, mgtDpDes); enableAntiStiction = acsParameters.targetModeControllerParameters.enableAntiStiction; break; @@ -429,8 +429,8 @@ void AcsController::performPointingCtrl() { ptgCtrl.ptgDesaturation( &acsParameters.gsTargetModeControllerParameters, mgmDataProcessed.mgmVecTot.value, mgmDataProcessed.mgmVecTot.isValid(), mekfData.satRotRateMekf.value, - &(sensorValues.rw1Set.currSpeed.value), &(sensorValues.rw2Set.currSpeed.value), - &(sensorValues.rw3Set.currSpeed.value), &(sensorValues.rw4Set.currSpeed.value), mgtDpDes); + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, mgtDpDes); enableAntiStiction = acsParameters.gsTargetModeControllerParameters.enableAntiStiction; break; @@ -453,8 +453,8 @@ void AcsController::performPointingCtrl() { ptgCtrl.ptgDesaturation( &acsParameters.nadirModeControllerParameters, mgmDataProcessed.mgmVecTot.value, mgmDataProcessed.mgmVecTot.isValid(), mekfData.satRotRateMekf.value, - &(sensorValues.rw1Set.currSpeed.value), &(sensorValues.rw2Set.currSpeed.value), - &(sensorValues.rw3Set.currSpeed.value), &(sensorValues.rw4Set.currSpeed.value), mgtDpDes); + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, mgtDpDes); enableAntiStiction = acsParameters.nadirModeControllerParameters.enableAntiStiction; break; @@ -476,8 +476,8 @@ void AcsController::performPointingCtrl() { ptgCtrl.ptgDesaturation( &acsParameters.inertialModeControllerParameters, mgmDataProcessed.mgmVecTot.value, mgmDataProcessed.mgmVecTot.isValid(), mekfData.satRotRateMekf.value, - &(sensorValues.rw1Set.currSpeed.value), &(sensorValues.rw2Set.currSpeed.value), - &(sensorValues.rw3Set.currSpeed.value), &(sensorValues.rw4Set.currSpeed.value), mgtDpDes); + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, mgtDpDes); enableAntiStiction = acsParameters.inertialModeControllerParameters.enableAntiStiction; break; default: From 8a65aca7b8186813c28432eff0e73f8766eaeed9 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 3 May 2023 09:43:02 +0200 Subject: [PATCH 019/172] someone seemed to like pointers way too much --- mission/controller/AcsController.cpp | 40 +++++++++++----------- mission/controller/acs/control/PtgCtrl.cpp | 8 ++--- mission/controller/acs/control/PtgCtrl.h | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index f3ed5cda..557a6105 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -375,10 +375,10 @@ void AcsController::performPointingCtrl() { targetSatRotRate, errorQuat, errorSatRotRate, errorAngle); ptgCtrl.ptgLaw(&acsParameters.idleModeControllerParameters, errorQuat, errorSatRotRate, *rwPseudoInv, torquePtgRws); - ptgCtrl.ptgNullspace( - &acsParameters.idleModeControllerParameters, &(sensorValues.rw1Set.currSpeed.value), - &(sensorValues.rw2Set.currSpeed.value), &(sensorValues.rw3Set.currSpeed.value), - &(sensorValues.rw4Set.currSpeed.value), rwTrqNs); + ptgCtrl.ptgNullspace(&acsParameters.idleModeControllerParameters, + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, + rwTrqNs); VectorOperations::add(torquePtgRws, rwTrqNs, torqueRws, 4); actuatorCmd.scalingTorqueRws(torqueRws, acsParameters.rwHandlingParameters.maxTrq); ptgCtrl.ptgDesaturation( @@ -399,10 +399,10 @@ void AcsController::performPointingCtrl() { errorSatRotRate, errorAngle); ptgCtrl.ptgLaw(&acsParameters.targetModeControllerParameters, errorQuat, errorSatRotRate, *rwPseudoInv, torquePtgRws); - ptgCtrl.ptgNullspace( - &acsParameters.targetModeControllerParameters, &(sensorValues.rw1Set.currSpeed.value), - &(sensorValues.rw2Set.currSpeed.value), &(sensorValues.rw3Set.currSpeed.value), - &(sensorValues.rw4Set.currSpeed.value), rwTrqNs); + ptgCtrl.ptgNullspace(&acsParameters.targetModeControllerParameters, + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, + rwTrqNs); VectorOperations::add(torquePtgRws, rwTrqNs, torqueRws, 4); actuatorCmd.scalingTorqueRws(torqueRws, acsParameters.rwHandlingParameters.maxTrq); ptgCtrl.ptgDesaturation( @@ -420,10 +420,10 @@ void AcsController::performPointingCtrl() { targetSatRotRate, errorQuat, errorSatRotRate, errorAngle); ptgCtrl.ptgLaw(&acsParameters.gsTargetModeControllerParameters, errorQuat, errorSatRotRate, *rwPseudoInv, torquePtgRws); - ptgCtrl.ptgNullspace( - &acsParameters.gsTargetModeControllerParameters, &(sensorValues.rw1Set.currSpeed.value), - &(sensorValues.rw2Set.currSpeed.value), &(sensorValues.rw3Set.currSpeed.value), - &(sensorValues.rw4Set.currSpeed.value), rwTrqNs); + ptgCtrl.ptgNullspace(&acsParameters.gsTargetModeControllerParameters, + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, + rwTrqNs); VectorOperations::add(torquePtgRws, rwTrqNs, torqueRws, 4); actuatorCmd.scalingTorqueRws(torqueRws, acsParameters.rwHandlingParameters.maxTrq); ptgCtrl.ptgDesaturation( @@ -444,10 +444,10 @@ void AcsController::performPointingCtrl() { errorSatRotRate, errorAngle); ptgCtrl.ptgLaw(&acsParameters.nadirModeControllerParameters, errorQuat, errorSatRotRate, *rwPseudoInv, torquePtgRws); - ptgCtrl.ptgNullspace( - &acsParameters.nadirModeControllerParameters, &(sensorValues.rw1Set.currSpeed.value), - &(sensorValues.rw2Set.currSpeed.value), &(sensorValues.rw3Set.currSpeed.value), - &(sensorValues.rw4Set.currSpeed.value), rwTrqNs); + ptgCtrl.ptgNullspace(&acsParameters.nadirModeControllerParameters, + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, + rwTrqNs); VectorOperations::add(torquePtgRws, rwTrqNs, torqueRws, 4); actuatorCmd.scalingTorqueRws(torqueRws, acsParameters.rwHandlingParameters.maxTrq); ptgCtrl.ptgDesaturation( @@ -467,10 +467,10 @@ void AcsController::performPointingCtrl() { errorSatRotRate, errorAngle); ptgCtrl.ptgLaw(&acsParameters.inertialModeControllerParameters, errorQuat, errorSatRotRate, *rwPseudoInv, torquePtgRws); - ptgCtrl.ptgNullspace( - &acsParameters.inertialModeControllerParameters, &(sensorValues.rw1Set.currSpeed.value), - &(sensorValues.rw2Set.currSpeed.value), &(sensorValues.rw3Set.currSpeed.value), - &(sensorValues.rw4Set.currSpeed.value), rwTrqNs); + ptgCtrl.ptgNullspace(&acsParameters.inertialModeControllerParameters, + sensorValues.rw1Set.currSpeed.value, sensorValues.rw2Set.currSpeed.value, + sensorValues.rw3Set.currSpeed.value, sensorValues.rw4Set.currSpeed.value, + rwTrqNs); VectorOperations::add(torquePtgRws, rwTrqNs, torqueRws, 4); actuatorCmd.scalingTorqueRws(torqueRws, acsParameters.rwHandlingParameters.maxTrq); ptgCtrl.ptgDesaturation( diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index c2c6e2b0..1ef88ccc 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -96,11 +96,11 @@ void PtgCtrl::ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters } void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawParameters, - const int32_t *speedRw0, const int32_t *speedRw1, - const int32_t *speedRw2, const int32_t *speedRw3, double *rwTrqNs) { + const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, + const int32_t speedRw3, double *rwTrqNs) { // concentrate RW speeds as vector and convert to double - double speedRws[4] = {static_cast(*speedRw0), static_cast(*speedRw1), - static_cast(*speedRw2), static_cast(*speedRw3)}; + double speedRws[4] = {static_cast(speedRw0), static_cast(speedRw1), + static_cast(speedRw2), static_cast(speedRw3)}; // calculate RPM offset utilizing the nullspace double rpmOffset[4] = {0, 0, 0, 0}; diff --git a/mission/controller/acs/control/PtgCtrl.h b/mission/controller/acs/control/PtgCtrl.h index f04950f9..5f731e6b 100644 --- a/mission/controller/acs/control/PtgCtrl.h +++ b/mission/controller/acs/control/PtgCtrl.h @@ -27,8 +27,8 @@ class PtgCtrl { const double *deltaRate, const double *rwPseudoInv, double *torqueRws); void ptgNullspace(AcsParameters::PointingLawParameters *pointingLawParameters, - const int32_t *speedRw0, const int32_t *speedRw1, const int32_t *speedRw2, - const int32_t *speedRw3, double *rwTrqNs); + const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, + const int32_t speedRw3, double *rwTrqNs); void ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawParameters, const double *magFieldB, const bool magFieldBValid, const double *satRate, From a7ccfae04e228890806d51db5dda4e7e7c3d9743 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:22:21 +0200 Subject: [PATCH 020/172] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75aa9c06..b627d3a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,11 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. +- The dual lane assembly transition failed handler started new transitions towards the current mode + instead of the target mode. This means that if the dual lane assembly never reached the initial + submode (e.g. mode normal and submode dual side), it will transition back to the current mode, + which is `MODE_OFF`. Furthermore, this lead to invalid internal states, so the subsequent + recovery handling becomes stuck in the custom recovery sequence when swichting power back on. # [v2.0.5] 2023-05-11 From 12749934282bbd7bdacb81989732b304134e043d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:23:21 +0200 Subject: [PATCH 021/172] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b627d3a9..f3b1b5da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,7 @@ will consitute of a breaking change warranting a new major release: - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, - which is `MODE_OFF`. Furthermore, this lead to invalid internal states, so the subsequent + which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent recovery handling becomes stuck in the custom recovery sequence when swichting power back on. # [v2.0.5] 2023-05-11 From c3604085c2d6a4a07220e7b26d91e4c47d9ffe77 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:28:05 +0200 Subject: [PATCH 022/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b1b5da..163ab8fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,8 @@ will consitute of a breaking change warranting a new major release: submode (e.g. mode normal and submode dual side), it will transition back to the current mode, which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent recovery handling becomes stuck in the custom recovery sequence when swichting power back on. +- The dual lane custom recovery handling was adapted to always perform proper power switch handling + irrespective of current or target modes. # [v2.0.5] 2023-05-11 From 09ece30304f11375b9f68c0bb0f88e89a4006f73 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 15:34:45 +0200 Subject: [PATCH 023/172] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 163ab8fa..ae1b5470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,9 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. + +# [v2.0.5] to be released + - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, From fa137033942870cecf78a50e92129b770e0cd7c0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:18:39 +0200 Subject: [PATCH 024/172] changelog --- CHANGELOG.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae1b5470..75aa9c06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,16 +49,6 @@ will consitute of a breaking change warranting a new major release: - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. -# [v2.0.5] to be released - -- The dual lane assembly transition failed handler started new transitions towards the current mode - instead of the target mode. This means that if the dual lane assembly never reached the initial - submode (e.g. mode normal and submode dual side), it will transition back to the current mode, - which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent - recovery handling becomes stuck in the custom recovery sequence when swichting power back on. -- The dual lane custom recovery handling was adapted to always perform proper power switch handling - irrespective of current or target modes. - # [v2.0.5] 2023-05-11 - The dual lane assembly transition failed handler started new transitions towards the current mode From 0a109e552daa513dc5212e33bb67900e46239d4b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 17:46:47 +0200 Subject: [PATCH 025/172] start adding flash read --- linux/payload/PlocMpsocHandler.cpp | 1 - linux/payload/PlocMpsocHelper.cpp | 30 ++++++++++++++++++++++-------- linux/payload/PlocMpsocHelper.h | 11 ++++++++--- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index cd405fa6..7583be76 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -207,7 +207,6 @@ void PlocMPSoCHandler::doShutDown() { #endif } - ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { *id = mpsoc::TC_GET_HK_REPORT; return buildCommandFromCommand(*id, nullptr, 0); diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocHelper.cpp index a22462e2..e0b832a4 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocHelper.cpp @@ -93,8 +93,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string } #endif - flashWrite.obcFile = obcFile; - flashWrite.mpsocFile = mpsocFile; + flashReadAndWrite.obcFile = obcFile; + flashReadAndWrite.mpsocFile = mpsocFile; internalState = InternalState::FLASH_WRITE; result = resetHelper(); if (result != returnvalue::OK) { @@ -116,12 +116,14 @@ void PlocMPSoCHelper::stopProcess() { terminate = true; } ReturnValue_t PlocMPSoCHelper::performFlashWrite() { ReturnValue_t result = returnvalue::OK; + std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary); + if (file.bad()) { + return returnvalue::FAILED; + } result = flashfopen(); if (result != returnvalue::OK) { return result; } - uint8_t tempData[mpsoc::MAX_DATA_SIZE]; - std::ifstream file(flashWrite.obcFile, std::ifstream::binary); // Set position of next character to end of file input stream file.seekg(0, file.end); // tellg returns position of character in input stream @@ -139,7 +141,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { } if (file.is_open()) { file.seekg(bytesRead, file.beg); - file.read(reinterpret_cast(tempData), dataLength); + file.read(reinterpret_cast(fileBuf.data()), dataLength); bytesRead += dataLength; remainingSize -= dataLength; } else { @@ -147,7 +149,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { } (*sequenceCount)++; mpsoc::TcFlashWrite tc(spParams, *sequenceCount); - result = tc.buildPacket(tempData, dataLength); + result = tc.buildPacket(fileBuf.data(), dataLength); if (result != returnvalue::OK) { return result; } @@ -163,12 +165,24 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { return result; } +ReturnValue_t PlocMPSoCHelper::performFlashRead() { + std::ofstream ofile(flashReadAndWrite.obcFile); + if (ofile.bad()) { + return returnvalue::FAILED; + } + ReturnValue_t result = flashfopen(); + if (result != returnvalue::OK) { + return result; + } + return result; +} + ReturnValue_t PlocMPSoCHelper::flashfopen() { ReturnValue_t result = returnvalue::OK; spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); - result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND); + result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND); if (result != returnvalue::OK) { return result; } @@ -184,7 +198,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() { spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); - result = flashFclose.createPacket(flashWrite.mpsocFile); + result = flashFclose.createPacket(flashReadAndWrite.mpsocFile); if (result != returnvalue::OK) { return result; } diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocHelper.h index b74c0844..1b74b568 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocHelper.h @@ -111,13 +111,16 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { // buffer static const int RETRIES = 10000; - struct FlashWrite { + struct FlashInfo { std::string obcFile; std::string mpsocFile; }; - struct FlashWrite flashWrite; + struct FlashRead : public FlashInfo { + size_t readSize = 0; + }; + struct FlashRead flashReadAndWrite; #if OBSW_THREAD_TRACING == 1 uint32_t opCounter = 0; #endif @@ -134,7 +137,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { SpacePacketCreator creator; ploc::SpTcParams spParams = ploc::SpTcParams(creator); - std::array tmBuf; + std::array fileBuf{}; + std::array tmBuf{}; bool terminate = false; @@ -150,6 +154,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { ReturnValue_t resetHelper(); ReturnValue_t performFlashWrite(); + ReturnValue_t performFlashRead(); ReturnValue_t flashfopen(); ReturnValue_t flashfclose(); ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc); From ff47fafdc28b66575097856bab335a3e07cf64b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 19:37:10 +0200 Subject: [PATCH 026/172] first flash read impl almost done --- linux/payload/PlocMpsocHelper.cpp | 153 +++++++++++++++++++++++++----- linux/payload/PlocMpsocHelper.h | 25 +++-- linux/payload/plocMpscoDefs.h | 63 ++++++++++-- 3 files changed, 199 insertions(+), 42 deletions(-) diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocHelper.cpp index e0b832a4..25bfc8d9 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocHelper.cpp @@ -51,6 +51,16 @@ ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { internalState = InternalState::IDLE; break; } + case InternalState::FLASH_READ: { + result = performFlashRead(); + if (result == returnvalue::OK) { + triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL); + } else { + triggerEvent(MPSOC_FLASH_READ_FAILED); + } + internalState = InternalState::IDLE; + break; + } default: sif::debug << "PlocMPSoCHelper::performOperation: Invalid state" << std::endl; break; @@ -132,29 +142,32 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { size_t bytesRead = 0; while (remainingSize > 0) { if (terminate) { + flashfclose(); return returnvalue::OK; } - if (remainingSize > mpsoc::MAX_DATA_SIZE) { - dataLength = mpsoc::MAX_DATA_SIZE; + if (remainingSize > mpsoc::SP_MAX_DATA_SIZE) { + dataLength = mpsoc::SP_MAX_DATA_SIZE; } else { dataLength = remainingSize; } - if (file.is_open()) { - file.seekg(bytesRead, file.beg); - file.read(reinterpret_cast(fileBuf.data()), dataLength); - bytesRead += dataLength; - remainingSize -= dataLength; - } else { - return FILE_CLOSED_ACCIDENTALLY; + if (file.bad() or not file.is_open()) { + flashfclose(); + return FILE_WRITE_ERROR; } + file.seekg(bytesRead, file.beg); + file.read(reinterpret_cast(fileBuf.data()), dataLength); + bytesRead += dataLength; + remainingSize -= dataLength; (*sequenceCount)++; mpsoc::TcFlashWrite tc(spParams, *sequenceCount); result = tc.buildPacket(fileBuf.data(), dataLength); if (result != returnvalue::OK) { + flashfclose(); return result; } - result = handlePacketTransmission(tc); + result = handlePacketTransmissionNoReply(tc); if (result != returnvalue::OK) { + flashfclose(); return result; } } @@ -166,27 +179,68 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { } ReturnValue_t PlocMPSoCHelper::performFlashRead() { - std::ofstream ofile(flashReadAndWrite.obcFile); + std::error_code e; + std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary); if (ofile.bad()) { return returnvalue::FAILED; } ReturnValue_t result = flashfopen(); if (result != returnvalue::OK) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); return result; } + size_t readSoFar = 0; + size_t nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE; + while (readSoFar < flashReadAndWrite.totalReadSize) { + if (terminate) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); + flashfclose(); + return returnvalue::OK; + } + nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE; + if (flashReadAndWrite.totalReadSize - readSoFar < mpsoc::MAX_FLASH_READ_DATA_SIZE) { + nextReadSize = flashReadAndWrite.totalReadSize - readSoFar; + } + if (ofile.bad() or not ofile.is_open()) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); + flashfclose(); + return FILE_READ_ERROR; + } + mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); + result = flashReadRequest.buildPacket(nextReadSize); + if (result != returnvalue::OK) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); + flashfclose(); + return result; + } + result = handlePacketTransmissionFlashRead(flashReadRequest); + if (result != returnvalue::OK) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); + flashfclose(); + return result; + } + result = handleFlashReadReply(ofile, nextReadSize); + if (result != returnvalue::OK) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); + flashfclose(); + return result; + } + (*sequenceCount)++; + readSoFar += nextReadSize; + } return result; } ReturnValue_t PlocMPSoCHelper::flashfopen() { - ReturnValue_t result = returnvalue::OK; spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); - result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND); + ReturnValue_t result = + flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND); if (result != returnvalue::OK) { return result; } - result = handlePacketTransmission(flashFopen); + result = handlePacketTransmissionNoReply(flashFopen); if (result != returnvalue::OK) { return result; } @@ -194,24 +248,18 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() { } ReturnValue_t PlocMPSoCHelper::flashfclose() { - ReturnValue_t result = returnvalue::OK; spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); - result = flashFclose.createPacket(flashReadAndWrite.mpsocFile); + ReturnValue_t result = flashFclose.createPacket(flashReadAndWrite.mpsocFile); if (result != returnvalue::OK) { return result; } - result = handlePacketTransmission(flashFclose); - if (result != returnvalue::OK) { - return result; - } - return returnvalue::OK; + return handlePacketTransmissionNoReply(flashFclose); } -ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(ploc::SpTcBase& tc) { - ReturnValue_t result = returnvalue::OK; - result = sendCommand(tc); +ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { + ReturnValue_t result = sendCommand(tc); if (result != returnvalue::OK) { return result; } @@ -219,11 +267,24 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(ploc::SpTcBase& tc) { if (result != returnvalue::OK) { return result; } - result = handleExe(); + result = handleTmReception(ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + + mpsoc::CRC_SIZE); if (result != returnvalue::OK) { return result; } - return returnvalue::OK; + return handleExe(); +} + +ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { + ReturnValue_t result = sendCommand(tc); + if (result != returnvalue::OK) { + return result; + } + result = handleAck(); + if (result != returnvalue::OK) { + return result; + } + return handleExe(); } ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) { @@ -323,6 +384,46 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) { return result; } +ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen) { + SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); + ReturnValue_t result = checkReceivedTm(tmPacket); + if (result != returnvalue::OK) { + return result; + } + uint16_t apid = tmPacket.getApid(); + if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) { + triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR); + sif::warning << "PLOC MPSoC Flash Read: Unexpected APID" << std::endl; + return result; + } + const uint8_t* packetData = tmPacket.getPacketData(); + size_t deserDummy = tmPacket.getPacketDataLen() - mpsoc::CRC_SIZE; + uint32_t receivedReadLen = 0; + std::string receivedShortName = std::string(reinterpret_cast(packetData), 12); + if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 12)) { + sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and " + "received file name" + << std::endl; + triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_FILENAME_ERROR); + return returnvalue::FAILED; + } + packetData += 12; + result = SerializeAdapter::deSerialize(&receivedReadLen, &packetData, &deserDummy, + SerializeIF::Endianness::NETWORK); + if (result != returnvalue::OK) { + return result; + } + if (receivedReadLen != expectedReadLen) { + sif::warning << "PLOC MPSoC Flash Read: Missmatch between request read length and " + "received read length" + << std::endl; + triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_READLEN_ERROR); + return returnvalue::FAILED; + } + ofile.write(reinterpret_cast(packetData), receivedReadLen); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t result = reader.checkSize(); if (result != returnvalue::OK) { diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocHelper.h index 1b74b568..24dd50a1 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocHelper.h @@ -29,7 +29,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { //! [EXPORT] : [COMMENT] Flash write fails static const Event MPSOC_FLASH_WRITE_FAILED = MAKE_EVENT(0, severity::LOW); //! [EXPORT] : [COMMENT] Flash write successful - static const Event MPSOC_FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(1, severity::LOW); + static const Event MPSOC_FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(1, severity::INFO); //! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command //! to the MPSoC //! P1: Return value returned by the communication interface sendMessage function @@ -71,6 +71,15 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { static const Event MPSOC_HELPER_SEQ_CNT_MISMATCH = MAKE_EVENT(11, severity::LOW); static const Event MPSOC_TM_SIZE_ERROR = MAKE_EVENT(12, severity::LOW); static const Event MPSOC_TM_CRC_MISSMATCH = MAKE_EVENT(13, severity::LOW); + static const Event MPSOC_FLASH_READ_PACKET_ERROR = MAKE_EVENT(14, severity::LOW); + static const Event MPSOC_FLASH_READ_FAILED = MAKE_EVENT(15, severity::LOW); + static const Event MPSOC_FLASH_READ_SUCCESSFUL = MAKE_EVENT(16, severity::INFO); + + enum FlashReadErrorType : uint32_t { + FLASH_READ_APID_ERROR = 0, + FLASH_READ_FILENAME_ERROR = 1, + FLASH_READ_READLEN_ERROR = 2 + }; PlocMPSoCHelper(object_id_t objectId); virtual ~PlocMPSoCHelper(); @@ -104,8 +113,10 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { private: static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER; - //! [EXPORT] : [COMMENT] File accidentally close - static const ReturnValue_t FILE_CLOSED_ACCIDENTALLY = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] File error occured for file transfers from OBC to the MPSoC. + static const ReturnValue_t FILE_WRITE_ERROR = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] File error occured for file transfers from MPSoC to OBC. + static const ReturnValue_t FILE_READ_ERROR = MAKE_RETURN_CODE(0xA1); // Maximum number of times the communication interface retries polling data from the reply // buffer @@ -117,7 +128,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { }; struct FlashRead : public FlashInfo { - size_t readSize = 0; + size_t totalReadSize = 0; }; struct FlashRead flashReadAndWrite; @@ -137,7 +148,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { SpacePacketCreator creator; ploc::SpTcParams spParams = ploc::SpTcParams(creator); - std::array fileBuf{}; + std::array fileBuf{}; std::array tmBuf{}; bool terminate = false; @@ -157,7 +168,9 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { ReturnValue_t performFlashRead(); ReturnValue_t flashfopen(); ReturnValue_t flashfclose(); - ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc); + ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc); + ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc); + ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen); ReturnValue_t sendCommand(ploc::SpTcBase& tc); ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes); ReturnValue_t handleAck(); diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 1ef72bf5..4c98e6e1 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -102,7 +102,8 @@ static const uint16_t TC_DOWNLINK_PWR_ON = 0x113; static const uint16_t TC_MEM_WRITE = 0x114; static const uint16_t TC_MEM_READ = 0x115; static const uint16_t TC_CAM_TAKE_PIC = 0x116; -static const uint16_t TC_FLASHWRITE = 0x117; +static constexpr uint16_t TC_FLASHWRITE = 0x117; +static constexpr uint16_t TC_FLASHREAD = 0x118; static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; static const uint16_t TC_FLASHDELETE = 0x11C; @@ -115,11 +116,12 @@ static constexpr uint16_t TM_HK_GET_REPORT = 0x408; static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124; static const uint16_t TC_CAM_CMD_SEND = 0x12C; static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130; -static const uint16_t TM_MEMORY_READ_REPORT = 0x404; static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; static const uint16_t EXE_SUCCESS = 0x402; static const uint16_t EXE_FAILURE = 0x403; +static const uint16_t TM_MEMORY_READ_REPORT = 0x404; +static const uint16_t TM_FLASH_READ_REPORT = 0x405; static const uint16_t TM_CAM_CMD_RPT = 0x407; } // namespace apid @@ -153,9 +155,13 @@ static const uint16_t LENGTH_TC_MEM_READ = 8; * at sheet README */ static constexpr size_t SP_MAX_SIZE = 1024; -static const size_t MAX_REPLY_SIZE = SP_MAX_SIZE * 3; -static const size_t MAX_COMMAND_SIZE = SP_MAX_SIZE; -static const size_t MAX_DATA_SIZE = 1016; +static constexpr size_t MAX_REPLY_SIZE = SP_MAX_SIZE * 3; +static constexpr size_t MAX_COMMAND_SIZE = SP_MAX_SIZE; +// 1016 bytes. +static constexpr size_t SP_MAX_DATA_SIZE = SP_MAX_SIZE - ccsds::HEADER_LEN - CRC_SIZE; +static constexpr size_t FLASH_READ_MIN_OVERHEAD = 16; +// 1000 bytes. +static const size_t MAX_FLASH_READ_DATA_SIZE = SP_MAX_DATA_SIZE - FLASH_READ_MIN_OVERHEAD; /** * The replay write sequence command has a maximum delay for the execution report which amounts to @@ -421,8 +427,8 @@ class TcFlashWrite : public ploc::SpTcBase { ReturnValue_t buildPacket(const uint8_t* writeData, uint32_t writeLen_) { ReturnValue_t result = returnvalue::OK; writeLen = writeLen_; - if (writeLen > MAX_DATA_SIZE) { - sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl; + if (writeLen > SP_MAX_DATA_SIZE) { + sif::error << "TcFlashWrite: Command data too big" << std::endl; return returnvalue::FAILED; } spParams.setFullPayloadLen(static_cast(writeLen) + 4 + CRC_SIZE); @@ -438,9 +444,9 @@ class TcFlashWrite : public ploc::SpTcBase { } std::memcpy(payloadStart + sizeof(writeLen), writeData, writeLen); updateSpFields(); - auto res = checkSizeAndSerializeHeader(); - if (res != returnvalue::OK) { - return res; + result = checkSizeAndSerializeHeader(); + if (result != returnvalue::OK) { + return result; } return calcAndSetCrc(); } @@ -449,6 +455,43 @@ class TcFlashWrite : public ploc::SpTcBase { uint32_t writeLen = 0; }; +class TcFlashRead : public ploc::SpTcBase { + public: + TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount) + : ploc::SpTcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} + + ReturnValue_t buildPacket(uint32_t readLen) { + if (readLen > MAX_FLASH_READ_DATA_SIZE) { + sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl; + return returnvalue::FAILED; + } + spParams.setFullPayloadLen(readLen + FLASH_READ_MIN_OVERHEAD + CRC_SIZE); + ReturnValue_t result = checkPayloadLen(); + if (result != returnvalue::OK) { + return result; + } + size_t serializedSize = ccsds::HEADER_LEN; + result = SerializeAdapter::serialize(&readLen, payloadStart, &serializedSize, spParams.maxSize, + SerializeIF::Endianness::NETWORK); + if (result != returnvalue::OK) { + return result; + } + updateSpFields(); + result = checkSizeAndSerializeHeader(); + if (result != returnvalue::OK) { + return result; + } + result = calcAndSetCrc(); + if (result != returnvalue::OK) { + return result; + } + readSize = readLen; + return result; + } + + uint32_t readSize = 0; +}; + /** * @brief Class to help creation of flash delete command. */ From 119afe61482dff33763194d15b6135d215160cdf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 19:49:45 +0200 Subject: [PATCH 027/172] now the helper just needs to be driven --- linux/payload/PlocMpsocHelper.cpp | 56 ++++++++++++++++++++----------- linux/payload/PlocMpsocHelper.h | 11 ++++++ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocHelper.cpp index 25bfc8d9..3eaa833d 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocHelper.cpp @@ -84,32 +84,22 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { } ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { - ReturnValue_t result = returnvalue::OK; -#ifdef XIPHOS_Q7S - result = FilesystemHelper::checkPath(obcFile); + ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile); if (result != returnvalue::OK) { return result; } - result = FilesystemHelper::fileExists(mpsocFile); - if (result != returnvalue::OK) { - return result; - } -#endif -#ifdef TE0720_1CFA - if (not std::filesystem::exists(obcFile)) { - sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist" - << std::endl; - return returnvalue::FAILED; - } -#endif - - flashReadAndWrite.obcFile = obcFile; - flashReadAndWrite.mpsocFile = mpsocFile; internalState = InternalState::FLASH_WRITE; - result = resetHelper(); + return result; +} + +ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, + size_t readFileSize) { + ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile); if (result != returnvalue::OK) { return result; } + flashReadAndWrite.totalReadSize = readFileSize; + internalState = InternalState::FLASH_READ; return result; } @@ -424,6 +414,34 @@ ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t return returnvalue::OK; } +ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { +#ifdef XIPHOS_Q7S + ReturnValue_t result = FilesystemHelper::checkPath(obcFile); + if (result != returnvalue::OK) { + return result; + } +#elif defined(TE0720_1CFA) + if (not std::filesystem::exists(obcFile)) { + sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist" + << std::endl; + return returnvalue::FAILED; + } +#endif + return returnvalue::OK; +} + +ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, + std::string mpsocFile) { + ReturnValue_t result = fileCheck(obcFile); + if (result != returnvalue::OK) { + return result; + } + + flashReadAndWrite.obcFile = obcFile; + flashReadAndWrite.mpsocFile = mpsocFile; + return resetHelper(); +} + ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t result = reader.checkSize(); if (result != returnvalue::OK) { diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocHelper.h index 24dd50a1..63a40d0c 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocHelper.h @@ -6,6 +6,7 @@ #include +#include "OBSWConfig.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/osal/linux/BinarySemaphore.h" @@ -99,6 +100,14 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { * @return returnvalue::OK if successful, otherwise error return value */ ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile); + /** + * + * @param obcFile Full target file name on OBC + * @param mpsocFile The file on the MPSoC which should be copied ot the OBC + * @param readFileSize The size of the file on the MPSoC. + * @return + */ + ReturnValue_t startFlashRead(std::string obcFile, std::string mpsocFile, size_t readFileSize); /** * @brief Can be used to interrupt a running data transfer. @@ -175,6 +184,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes); ReturnValue_t handleAck(); ReturnValue_t handleExe(); + ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); + ReturnValue_t fileCheck(std::string obcFile); void handleAckApidFailure(uint16_t apid); void handleExeApidFailure(uint16_t apid); ReturnValue_t handleTmReception(size_t remainingBytes); From e4431d20c4842e1c94c5dcf2475c9202572d02ba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 19:54:30 +0200 Subject: [PATCH 028/172] driving code almost done as well --- linux/payload/PlocMpsocHandler.cpp | 8 +++++++- linux/payload/plocMpscoDefs.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 7583be76..2cbc66af 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -124,7 +124,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI } switch (actionId) { - case mpsoc::TC_FLASHWRITE: { + case mpsoc::TC_FLASH_WRITE_FULL_FILE: { if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { return MPSoCReturnValuesIF::FILENAME_TOO_LONG; } @@ -141,6 +141,10 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI plocMPSoCHelperExecuting = true; return EXECUTION_FINISHED; } + case mpsoc::TC_FLASH_READ_FULL_FILE: { + // TODO: Finsh this. + break; + } case (mpsoc::OBSW_RESET_SEQ_COUNT): { sequenceCount = 0; return EXECUTION_FINISHED; @@ -307,6 +311,8 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::TC_MEM_WRITE); this->insertInCommandMap(mpsoc::TC_MEM_READ); this->insertInCommandMap(mpsoc::TC_FLASHDELETE); + insertInCommandMap(mpsoc::TC_FLASH_WRITE_FULL_FILE); + insertInCommandMap(mpsoc::TC_FLASH_READ_FULL_FILE); this->insertInCommandMap(mpsoc::TC_REPLAY_START); this->insertInCommandMap(mpsoc::TC_REPLAY_STOP); this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_ON); diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 4c98e6e1..cbb4f1f8 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -62,7 +62,7 @@ static const DeviceCommandId_t EXE_REPORT = 5; static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 6; static const DeviceCommandId_t TC_FLASHFOPEN = 7; static const DeviceCommandId_t TC_FLASHFCLOSE = 8; -static const DeviceCommandId_t TC_FLASHWRITE = 9; +static const DeviceCommandId_t TC_FLASH_WRITE_FULL_FILE = 9; static const DeviceCommandId_t TC_FLASHDELETE = 10; static const DeviceCommandId_t TC_REPLAY_START = 11; static const DeviceCommandId_t TC_REPLAY_STOP = 12; @@ -81,6 +81,7 @@ static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24; static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25; static const DeviceCommandId_t TC_GET_HK_REPORT = 26; static const DeviceCommandId_t TM_GET_HK_REPORT = 27; +static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30; // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; From ff175170aaff43495c1920ac8f678eca5e20e2ef Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:19:46 +0200 Subject: [PATCH 029/172] start adding dir content report --- linux/payload/plocMpscoDefs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index cbb4f1f8..7e862ba3 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -81,8 +81,11 @@ static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24; static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25; static const DeviceCommandId_t TC_GET_HK_REPORT = 26; static const DeviceCommandId_t TM_GET_HK_REPORT = 27; +static const DeviceCommandId_t TC_FLASH_GET_DIRECTORY_CONTENT = 28; +static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29; static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30; + // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; @@ -107,6 +110,7 @@ static constexpr uint16_t TC_FLASHWRITE = 0x117; static constexpr uint16_t TC_FLASHREAD = 0x118; static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; +static constexpr uint16_t TC_FLASH_GET_DIRECTORY_CONTENT = 0x11B; static const uint16_t TC_FLASHDELETE = 0x11C; static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_REPLAY = 0x11F; @@ -121,8 +125,12 @@ static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; static const uint16_t EXE_SUCCESS = 0x402; static const uint16_t EXE_FAILURE = 0x403; +<<<<<<< HEAD static const uint16_t TM_MEMORY_READ_REPORT = 0x404; static const uint16_t TM_FLASH_READ_REPORT = 0x405; +======= +static constexpr uint16_t TM_FLASH_DIRECTORY_CONTENT = 0x406; +>>>>>>> 98ede40d (start adding dir content report) static const uint16_t TM_CAM_CMD_RPT = 0x407; } // namespace apid From 5b4261104ef83e8db254cbde13d0a35ec77e1bcf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:20:47 +0200 Subject: [PATCH 030/172] add some more commands --- linux/payload/plocMpscoDefs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 7e862ba3..c3a2bc35 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -112,26 +112,26 @@ static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; static constexpr uint16_t TC_FLASH_GET_DIRECTORY_CONTENT = 0x11B; static const uint16_t TC_FLASHDELETE = 0x11C; +static constexpr uint16_t TC_FLASH_CREATE_DIR = 0x11D; static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_REPLAY = 0x11F; static const uint16_t TC_MODE_SNAPSHOT = 0x120; static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121; static constexpr uint16_t TC_HK_GET_REPORT = 0x123; -static constexpr uint16_t TM_HK_GET_REPORT = 0x408; static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124; static const uint16_t TC_CAM_CMD_SEND = 0x12C; +static constexpr uint16_t TC_FLASH_COPY_FILE = 0x12E; static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130; + static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; static const uint16_t EXE_SUCCESS = 0x402; static const uint16_t EXE_FAILURE = 0x403; -<<<<<<< HEAD static const uint16_t TM_MEMORY_READ_REPORT = 0x404; static const uint16_t TM_FLASH_READ_REPORT = 0x405; -======= static constexpr uint16_t TM_FLASH_DIRECTORY_CONTENT = 0x406; ->>>>>>> 98ede40d (start adding dir content report) static const uint16_t TM_CAM_CMD_RPT = 0x407; +static constexpr uint16_t TM_HK_GET_REPORT = 0x408; } // namespace apid /** Offset from first byte in space packet to first byte of data field */ From 827419ef34ea29ad1e5f1e58fa2a08df26287a2f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 15:24:47 +0200 Subject: [PATCH 031/172] implement dir content report in OBSW --- linux/payload/PlocMpsocHandler.cpp | 83 +++++++++++++++++++++++------- linux/payload/PlocMpsocHandler.h | 3 +- linux/payload/plocMpscoDefs.h | 17 ++++++ 3 files changed, 83 insertions(+), 20 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 2cbc66af..78093740 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -262,6 +262,10 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device result = prepareTcGetHkReport(); break; } + case (mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT): { + result = prepareTcGetDirContent(commandData, commandDataLen); + break; + } case (mpsoc::TC_MODE_REPLAY): { result = prepareTcModeReplay(); break; @@ -325,14 +329,16 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::RELEASE_UART_TX); this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE); this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC); + this->insertInCommandMap(mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT); this->insertInCommandMap(mpsoc::TC_SIMPLEX_SEND_FILE); this->insertInCommandMap(mpsoc::TC_DOWNLINK_DATA_MODULATE); this->insertInCommandMap(mpsoc::TC_MODE_SNAPSHOT); this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); - this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, 0); + this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, mpsoc::SIZE_TM_HK_REPORT); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); + this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, 0); } ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, @@ -350,6 +356,11 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain } uint16_t apid = spacePacket.getApid(); + auto handleDedicatedReply = [&](DeviceCommandId_t replyId) { + *foundLen = spacePacket.getFullPacketLen(); + foundPacketLen = *foundLen; + *foundId = replyId; + }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): *foundLen = mpsoc::SIZE_ACK_REPORT; @@ -364,14 +375,14 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain *foundId = mpsoc::TM_MEMORY_READ_REPORT; break; case (mpsoc::apid::TM_CAM_CMD_RPT): - *foundLen = spacePacket.getFullPacketLen(); - foundPacketLen = *foundLen; - *foundId = mpsoc::TM_CAM_CMD_RPT; + handleDedicatedReply(mpsoc::TM_CAM_CMD_RPT); break; case (mpsoc::apid::TM_HK_GET_REPORT): { - *foundLen = spacePacket.getFullPacketLen(); - foundPacketLen = *foundLen; - *foundId = mpsoc::TM_GET_HK_REPORT; + handleDedicatedReply(mpsoc::TM_GET_HK_REPORT); + break; + } + case (mpsoc::apid::TM_FLASH_DIRECTORY_CONTENT): { + handleDedicatedReply(mpsoc::TM_FLASH_DIRECTORY_CONTENT); break; } case (mpsoc::apid::EXE_SUCCESS): @@ -419,6 +430,18 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const result = handleCamCmdRpt(packet); break; } + case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): { + result = verifyPacket(packet, foundPacketLen); + if (result == MPSoCReturnValuesIF::CRC_FAILURE) { + sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl; + } + /** Send data to commanding queue */ + handleDeviceTm(packet + mpsoc::DATA_FIELD_OFFSET, + foundPacketLen - mpsoc::DATA_FIELD_OFFSET - mpsoc::CRC_SIZE, + mpsoc::TM_FLASH_DIRECTORY_CONTENT); + nextReplyId = mpsoc::EXE_REPORT; + return result; + } case (mpsoc::EXE_REPORT): { result = handleExecutionReport(packet); break; @@ -432,7 +455,10 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { + PoolReadGuard pg(&hkReport); + hkReport.setValidity(false, true); +} uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } @@ -635,9 +661,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); - result = tcCamTakePic.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } @@ -647,9 +672,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); - result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } @@ -657,11 +681,21 @@ ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandD return returnvalue::OK; } +ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData, + size_t commandDataLen) { + mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount); + ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen); + if (result != returnvalue::OK) { + return result; + } + finishTcPrep(tcGetDirContent.getFullPacketLen()); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); - result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } @@ -670,9 +704,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com } ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); - result = tcModeSnapshot.buildPacket(); + ReturnValue_t result = tcModeSnapshot.buildPacket(); if (result != returnvalue::OK) { return result; } @@ -792,7 +825,7 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { uint16_t memLen = *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1); /** Send data to commanding queue */ - handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4, + handleDeviceTm(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4, mpsoc::TM_MEMORY_READ_REPORT); nextReplyId = mpsoc::EXE_REPORT; return result; @@ -991,7 +1024,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex << static_cast(ackValue) << std::endl; #endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */ - handleDeviceTM(packetReader.getPacketData() + sizeof(uint16_t), + handleDeviceTm(packetReader.getPacketData() + sizeof(uint16_t), packetReader.getPacketDataLen() - 1, mpsoc::TM_CAM_CMD_RPT); return result; } @@ -1050,6 +1083,13 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator } break; } + case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: { + result = enableThreeReplies(mpsoc::TM_FLASH_DIRECTORY_CONTENT); + if (result != returnvalue::OK) { + return result; + } + break; + } case mpsoc::OBSW_RESET_SEQ_COUNT: break; default: @@ -1116,6 +1156,7 @@ void PlocMPSoCHandler::setNextReplyId() { break; } } + size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t replyLen = 0; @@ -1217,7 +1258,7 @@ void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue handleActionCommandFailure(actionId); } -void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, +void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { ReturnValue_t result = returnvalue::OK; @@ -1286,6 +1327,10 @@ void PlocMPSoCHandler::disableAllReplies() { disableCommandWithReply(TM_GET_HK_REPORT); break; } + case TC_FLASH_GET_DIRECTORY_CONTENT: { + disableCommandWithReply(TM_FLASH_DIRECTORY_CONTENT); + break; + } case TC_CAM_CMD_SEND: { disableCommandWithReply(TM_CAM_CMD_RPT); break; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index c9850e18..a6a866ef 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -201,6 +201,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcDownlinkPwrOff(); ReturnValue_t prepareTcGetHkReport(); + ReturnValue_t prepareTcGetDirContent(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcModeIdle(); @@ -266,7 +267,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { * @param dataSize Size of telemetry in bytes. * @param replyId Id of the reply. This will be added to the ActionMessage. */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + void handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); /** * @brief In case an acknowledgment failure reply has been received this function disables diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index c3a2bc35..9cdd4515 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -669,6 +669,23 @@ class TcGetHkReport : public TcBase { : TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {} }; +class TcGetDirContent : public TcBase { + public: + TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount) + : TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {} + + ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { + ReturnValue_t result = returnvalue::OK; + spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE); + if (result != returnvalue::OK) { + return result; + } + std::memcpy(payloadStart, commandData, commandDataLen); + *(payloadStart + commandDataLen) = NULL_TERMINATOR; + return result; + } +}; + /** * @brief Class to build replay stop space packet. */ From 98ef38f3eb0c7c22839d50e16a29e2b4741f3939 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 15:30:30 +0200 Subject: [PATCH 032/172] i think that should do the job --- linux/payload/PlocMpsocHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 78093740..25996b1a 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1181,6 +1181,10 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { // report is not fixed replyLen = mpsoc::SP_MAX_SIZE; break; + case mpsoc::TM_FLASH_DIRECTORY_CONTENT: + // I think the reply size is not fixed either. + replyLen = mpsoc::SP_MAX_SIZE; + break; default: { replyLen = iter->second.replyLen; break; From 71ef1edb683f02e14e3329501b939b725b7661e8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:21:07 +0200 Subject: [PATCH 033/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75aa9c06..5592997c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ will consitute of a breaking change warranting a new major release: - Add ACS board for EM by default now. - Add support for MPSoC HK packet. - Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands. +- Add support for MPSoC Flash Directory Content Report. ## Added From f72c797f53f6a9d47f2510fd79537b189219d7c6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:21:44 +0200 Subject: [PATCH 034/172] this should do the job --- CHANGELOG.md | 2 + common/config/eive/definitions.h | 4 +- linux/payload/PlocMpsocHandler.cpp | 19 ++++++--- linux/payload/PlocMpsocHelper.cpp | 8 ++-- linux/payload/plocMpscoDefs.h | 59 ++++++++++++++++++++------ mission/acs/str/StarTrackerHandler.cpp | 17 ++++---- mission/acs/str/StarTrackerHandler.h | 3 -- 7 files changed, 77 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5592997c..d4fa7a22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ will consitute of a breaking change warranting a new major release: - Add support for MPSoC HK packet. - Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands. - Add support for MPSoC Flash Directory Content Report. +- Larger allowed path and file sizes for STR and PLOC MPSoC modules. +- More robust MPSoC flash read and write command data handling. ## Added diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index 8c460f53..78ba52e4 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -34,8 +34,8 @@ static constexpr uint32_t STR_IMG_HELPER_QUEUE_SIZE = 50; static constexpr uint8_t LIVE_TM = 0; /* Limits for filename and path checks */ -static constexpr uint32_t MAX_PATH_SIZE = 100; -static constexpr uint32_t MAX_FILENAME_SIZE = 50; +static constexpr uint32_t MAX_PATH_SIZE = 200; +static constexpr uint32_t MAX_FILENAME_SIZE = 100; static constexpr uint32_t SA_DEPL_INIT_BUFFER_SECS = 120; // Burn time for autonomous deployment diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 25996b1a..3462859b 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -125,10 +125,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI switch (actionId) { case mpsoc::TC_FLASH_WRITE_FULL_FILE: { - if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { - return MPSoCReturnValuesIF::FILENAME_TOO_LONG; - } - mpsoc::FlashWritePusCmd flashWritePusCmd; + mpsoc::FlashBasePusCmd flashWritePusCmd; result = flashWritePusCmd.extractFields(data, size); if (result != returnvalue::OK) { return result; @@ -142,7 +139,19 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI return EXECUTION_FINISHED; } case mpsoc::TC_FLASH_READ_FULL_FILE: { - // TODO: Finsh this. + mpsoc::FlashReadPusCmd flashReadPusCmd; + result = flashReadPusCmd.extractFields(data, size); + if (result != returnvalue::OK) { + return result; + } + result = plocMPSoCHelper->startFlashRead(flashReadPusCmd.getObcFile(), + flashReadPusCmd.getMPSoCFile(), + flashReadPusCmd.getReadSize()); + if (result != returnvalue::OK) { + return result; + } + plocMPSoCHelperExecuting = true; + return EXECUTION_FINISHED; break; } case (mpsoc::OBSW_RESET_SEQ_COUNT): { diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocHelper.cpp index 3eaa833d..421ac83c 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocHelper.cpp @@ -84,7 +84,7 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { } ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { - ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile); + ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile)); if (result != returnvalue::OK) { return result; } @@ -94,7 +94,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, size_t readFileSize) { - ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile); + ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile)); if (result != returnvalue::OK) { return result; } @@ -437,8 +437,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, return result; } - flashReadAndWrite.obcFile = obcFile; - flashReadAndWrite.mpsocFile = mpsocFile; + flashReadAndWrite.obcFile = std::move(obcFile); + flashReadAndWrite.mpsocFile = std::move(mpsocFile); return resetHelper(); } diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 9cdd4515..d7bfa028 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -736,36 +736,69 @@ class TcReplayWriteSeq : public TcBase { /** * @brief Helps to extract the fields of the flash write command from the PUS packet. */ -class FlashWritePusCmd : public MPSoCReturnValuesIF { +class FlashBasePusCmd : public MPSoCReturnValuesIF { public: - FlashWritePusCmd(){}; + FlashBasePusCmd() = default; + virtual ~FlashBasePusCmd() = default; - ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) { + virtual ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) { return INVALID_LENGTH; } - obcFile = std::string(reinterpret_cast(commandData)); - if (obcFile.size() > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) { + size_t fileLen = strnlen(reinterpret_cast(commandData), commandDataLen); + if (fileLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) { return FILENAME_TOO_LONG; } - mpsocFile = std::string( - reinterpret_cast(commandData + obcFile.size() + SIZE_NULL_TERMINATOR)); - if (mpsocFile.size() > MAX_FILENAME_SIZE) { + obcFile = std::string(reinterpret_cast(commandData), fileLen); + fileLen = + strnlen(reinterpret_cast(commandData + obcFile.size() + SIZE_NULL_TERMINATOR), + commandDataLen - obcFile.size() - 1); + if (fileLen > MAX_FILENAME_SIZE) { return MPSOC_FILENAME_TOO_LONG; } + mpsocFile = std::string( + reinterpret_cast(commandData + obcFile.size() + SIZE_NULL_TERMINATOR), + fileLen); return returnvalue::OK; } - std::string getObcFile() { return obcFile; } + const std::string& getObcFile() const { return obcFile; } - std::string getMPSoCFile() { return mpsocFile; } + const std::string& getMPSoCFile() const { return mpsocFile; } + + protected: + size_t getParsedSize() const { + return getObcFile().size() + getMPSoCFile().size() + 2 * SIZE_NULL_TERMINATOR; + } + static const size_t SIZE_NULL_TERMINATOR = 1; private: - static const size_t SIZE_NULL_TERMINATOR = 1; - std::string obcFile = ""; - std::string mpsocFile = ""; + std::string obcFile; + std::string mpsocFile; }; +class FlashReadPusCmd : public FlashBasePusCmd { + public: + FlashReadPusCmd(){}; + + ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t result = FlashBasePusCmd::extractFields(commandData, commandDataLen); + if (result != returnvalue::OK) { + return result; + } + if (commandDataLen < (getParsedSize() + 4)) { + return returnvalue::FAILED; + } + size_t deserDummy = 4; + return SerializeAdapter::deSerialize(&readSize, commandData + getParsedSize(), &deserDummy, + SerializeIF::Endianness::NETWORK); + } + + size_t getReadSize() const { return readSize; } + + private: + size_t readSize = 0; +}; /** * @brief Class to build replay stop space packet. */ diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index d40e5fab..0942164a 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -17,6 +17,7 @@ extern "C" { #include #include "OBSWConfig.h" +#include "eive/definitions.h" std::atomic_bool JCFG_DONE(false); @@ -152,7 +153,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu return EXECUTION_FINISHED; } case (startracker::SET_JSON_FILE_NAME): { - if (size > MAX_PATH_SIZE) { + if (size > config::MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } paramJsonFile = std::string(reinterpret_cast(data), size); @@ -189,7 +190,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (result != returnvalue::OK) { return result; } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { return FILE_PATH_TOO_LONG; } result = strHelper->startImageUpload(std::string(reinterpret_cast(data), size)); @@ -204,7 +205,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (result != returnvalue::OK) { return result; } - if (size > MAX_PATH_SIZE) { + if (size > config::MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } result = @@ -228,14 +229,14 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu return EXECUTION_FINISHED; } case (startracker::CHANGE_IMAGE_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { + if (size > config::MAX_FILENAME_SIZE) { return FILENAME_TOO_LONG; } strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } case (startracker::SET_FLASH_READ_FILENAME): { - if (size > MAX_FILE_NAME) { + if (size > config::MAX_FILENAME_SIZE) { return FILENAME_TOO_LONG; } strHelper->setFlashReadFilename(std::string(reinterpret_cast(data), size)); @@ -246,7 +247,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu if (result != returnvalue::OK) { return result; } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { + if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { return FILE_PATH_TOO_LONG; } result = @@ -1568,7 +1569,7 @@ ReturnValue_t StarTrackerHandler::executeFlashReadCommand(const uint8_t* command << std::endl; return result; } - if (commandDataLen - sizeof(startRegion) - sizeof(length) > MAX_PATH_SIZE) { + if (commandDataLen - sizeof(startRegion) - sizeof(length) > config::MAX_PATH_SIZE) { sif::warning << "StarTrackerHandler::executeFlashReadCommand: Received command with invalid" << " path and filename" << std::endl; return FILE_PATH_TOO_LONG; @@ -1708,7 +1709,7 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData bool reinitSet) { // Stopwatch watch; ReturnValue_t result = returnvalue::OK; - if (commandDataLen > MAX_PATH_SIZE) { + if (commandDataLen > config::MAX_PATH_SIZE) { return FILE_PATH_TOO_LONG; } if (reinitSet) { diff --git a/mission/acs/str/StarTrackerHandler.h b/mission/acs/str/StarTrackerHandler.h index a74bff44..7bcc9f2a 100644 --- a/mission/acs/str/StarTrackerHandler.h +++ b/mission/acs/str/StarTrackerHandler.h @@ -144,9 +144,6 @@ class StarTrackerHandler : public DeviceHandlerBase { //! [EXPORT] : [COMMENT] Failed to boot star tracker into bootloader mode static const Event BOOTING_BOOTLOADER_FAILED_EVENT = MAKE_EVENT(2, severity::LOW); - static const size_t MAX_PATH_SIZE = 50; - static const size_t MAX_FILE_NAME = 30; - static const uint8_t STATUS_OFFSET = 2; static const uint8_t PARAMS_OFFSET = 2; static const uint8_t TICKS_OFFSET = 3; From 119b1c8eb9b2212b9fc87b7ff3ade7160ceebf83 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 20:22:10 +0200 Subject: [PATCH 035/172] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 5fbd19bb..13fd9a7d 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5fbd19bb6cca0790373a809d78f2307adca9d0c8 +Subproject commit 13fd9a7d84645535496e9ff2855118e5d0b59916 From 7e6c25901bb8d73cb23d74a13fe03d4eafeb6b8d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 09:13:02 +0200 Subject: [PATCH 036/172] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit c137df64ab43e5b20fcf26c8821982fa71e43cff Merge: a919b3d1 4179e8e1 Author: Robin Mueller Date: Fri Apr 28 15:38:52 2023 +0200 Merge remote-tracking branch 'origin/main' into update_ptme_code commit 4179e8e124b3f9f425ac64b7df8b7e7395982dbf Merge: 26f5eff6 51f9d5e1 Author: Robin Müller Date: Fri Apr 28 15:35:54 2023 +0200 Merge pull request 'This bugfix might be super important' (#621) from possible_bugfix_dual_lane_assy into main Reviewed-on: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/621 Reviewed-by: Marius Eggert Reviewed-by: Steffen Gaisser commit 51f9d5e1fe8e71445ec15b833020c4e30b254e72 Merge: a17f57cb 26f5eff6 Author: Robin Müller Date: Fri Apr 28 15:35:10 2023 +0200 Merge branch 'main' into possible_bugfix_dual_lane_assy commit a17f57cbb587f960366baae7059309d18619cdc4 Author: Robin Mueller Date: Fri Apr 28 15:34:45 2023 +0200 changelog commit 26f5eff6d5957e4898f6d5a84200e77b1bd6250c Merge: 4074e084 8a0f13ba Author: Robin Müller Date: Fri Apr 28 15:32:03 2023 +0200 Merge pull request 'More System Modes' (#612) from more-system-modes into main Reviewed-on: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/612 commit 8a0f13bafbb995b724321a3936a674078d01882f Merge: 14baa356 4074e084 Author: Robin Müller Date: Fri Apr 28 15:31:51 2023 +0200 Merge branch 'main' into more-system-modes commit 14baa3563c3dc6499bac49bb83c08ba98bfad171 Author: Robin Mueller Date: Fri Apr 28 15:30:09 2023 +0200 hello commit 7045b6034afdb819f4978f91f697d7f23806ab89 Author: Robin Mueller Date: Fri Apr 28 15:18:47 2023 +0200 changelog commit 37b9615525637294118266910979236127f8a8ce Author: Robin Mueller Date: Fri Apr 28 15:18:16 2023 +0200 changelog commit 4074e0848012042565047726b8c526c6b5809a2c Merge: 862a4f26 38686ac3 Author: Robin Müller Date: Fri Apr 28 15:12:46 2023 +0200 Merge pull request 'Adaption for EM: Add P60 dock without ACU' (#620) from adaption_em_p60_dock_without_acu into main Reviewed-on: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/620 Reviewed-by: Marius Eggert commit 23796345d966787f6f43c1d89b9555413bfe583a Author: Robin Mueller Date: Fri Apr 28 15:04:30 2023 +0200 changelog and stop payload tracking commit b10275ca43f13ee68be013c7ece3b63acf762130 Author: Robin Mueller Date: Fri Apr 28 14:28:05 2023 +0200 changelog commit 383849c5cb62b1543037ab07c904b2725c91be13 Author: Robin Mueller Date: Fri Apr 28 14:25:14 2023 +0200 that is more robust commit c66cef9129586e8708a8f2679ff86b3c9977c5f5 Author: Robin Mueller Date: Fri Apr 28 14:23:21 2023 +0200 changelog commit 02ea8a7298ff14c8acab55b2f693e8593c277624 Author: Robin Mueller Date: Fri Apr 28 14:22:21 2023 +0200 changelog commit 38686ac3f621e50ea76be023520167841d2e2c19 Merge: 189a3126 74d5d709 Author: Robin Mueller Date: Fri Apr 28 14:04:03 2023 +0200 Merge branch 'possible_bugfix_dual_lane_assy' into adaption_em_p60_dock_without_acu commit 74d5d70973b46c70d1483077e71e2820d3ca4ad6 Author: Robin Mueller Date: Fri Apr 28 13:58:08 2023 +0200 this bugfix might be super important commit 48355e82635b071b9347b62f2bd1da636bf4eae5 Merge: 5691fe8e 862a4f26 Author: Robin Müller Date: Fri Apr 28 10:25:50 2023 +0200 Merge branch 'main' into more-system-modes commit 189a312628e561f54491ec238a2d2d5e2f211b57 Merge: a1279428 862a4f26 Author: Robin Mueller Date: Fri Apr 28 10:23:46 2023 +0200 Merge remote-tracking branch 'origin/main' into adaption_em_p60_dock_without_acu commit a12794281bfc2ebb27a02bbc151696023e69a9f0 Author: Robin Mueller Date: Fri Apr 28 10:20:31 2023 +0200 changelog commit fcaabb4e421b5f792ede490b6dd135ce661c9db5 Merge: 6c326489 4aafca64 Author: Robin Mueller Date: Fri Apr 28 10:20:02 2023 +0200 Merge remote-tracking branch 'origin/main' into adaption_em_p60_dock_without_acu commit 6c326489cbc59f2d70993542f05676472ca0102f Author: Robin Mueller Date: Fri Apr 28 10:18:46 2023 +0200 adapt EM SW: GS PCDU added, but use dummy for ACU commit 862a4f268510e04fc3cfb878b5eed9f0f9d62f05 Merge: 4aafca64 2daca272 Author: Robin Müller Date: Fri Apr 28 09:37:55 2023 +0200 Merge pull request 'Host SW bugfixes' (#618) from try_fix_host_obsw into main Reviewed-on: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/618 Reviewed-by: Marius Eggert commit 5691fe8e72a2e3b008d6130f31be32d9d7aee9b7 Merge: 097be17a 4aafca64 Author: meggert Date: Thu Apr 27 15:40:31 2023 +0200 Merge branch 'main' into more-system-modes commit 2daca272f8f0397125349c0f6c193e22d0a26383 Author: Robin Mueller Date: Thu Apr 27 11:29:18 2023 +0200 changelog commit 03762f962020b55188d445ee3dd429b6e1a32135 Author: Robin Mueller Date: Wed Apr 26 17:38:06 2023 +0200 lower live TM handler frequency commit a296f16e5ce9d803ce5db54d9602e396dad7ebce Author: Robin Mueller Date: Wed Apr 26 17:36:38 2023 +0200 host SW works properly again commit 83f07a6e16cbbf5fc4a9ccb2e7d92c3fdffb172b Author: Robin Mueller Date: Wed Apr 26 17:26:32 2023 +0200 configurable event manager queue depth commit 00dab64628a53d2109fceb5f9a4ffc765a72fab6 Merge: 641b8e84 4aafca64 Author: Robin Mueller Date: Wed Apr 26 17:03:35 2023 +0200 Merge remote-tracking branch 'origin/main' into try_fix_host_obsw commit 4aafca64a67589826f1578865c92fa76141e8531 Merge: f271242d 6901eae8 Author: Robin Müller Date: Wed Apr 26 17:03:01 2023 +0200 Merge pull request 'EM adaptions' (#619) from em_adaptions into main Reviewed-on: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/619 commit 6901eae81689981937e7eb49b98886f8c78b727b Merge: 7d630ebc f271242d Author: Robin Mueller Date: Wed Apr 26 17:02:24 2023 +0200 Merge remote-tracking branch 'origin/main' into em_adaptions commit 7d630ebcf3894a9a9896d1c3f05548d5ef230333 Author: Robin Mueller Date: Wed Apr 26 17:00:04 2023 +0200 EM adaptions commit 641b8e847d2b63ad11f28c4a37434a6161443690 Author: Robin Mueller Date: Wed Apr 26 16:41:40 2023 +0200 add back tm funnel handler for hosted build commit 13142686823bedee1a79ae5f851f124968822a54 Author: Robin Mueller Date: Wed Apr 26 16:23:50 2023 +0200 host build requires dedicated live TM task.. commit 4040304ef09a172f9d2bef42547d6b1effb8ca76 Author: Robin Mueller Date: Wed Apr 26 13:15:42 2023 +0200 this is annoying commit a919b3d1645d5c4a6e20903d973ce96424508cae Merge: e22f2a53 9672d6d6 Author: Robin Mueller Date: Wed Apr 26 11:11:30 2023 +0200 Merge remote-tracking branch 'origin/develop' into update_ptme_code commit 9672d6d6cca3ad7369bb4b06fd91a7f17a0f9db9 Author: Robin Mueller Date: Wed Apr 26 11:11:09 2023 +0200 changelog commit e22f2a53ea7388cc5c75c2024953aab293c8d277 Merge: b076e80b 0eb6b7cc Author: Robin Mueller Date: Wed Apr 26 11:05:58 2023 +0200 Merge remote-tracking branch 'origin/develop' into update_ptme_code commit b076e80b44e7ef2b2417def66ec1f1a684cfb228 Author: Robin Mueller Date: Wed Apr 26 11:04:10 2023 +0200 changelog commit 269aa6f7b0006125e9a516f8ecb6cdc32c91cbe5 Author: Robin Mueller Date: Wed Apr 26 11:03:42 2023 +0200 changelog commit caae2b4ba925747aa0ed1e2112582c6deff39d77 Author: Robin Mueller Date: Wed Apr 26 11:02:24 2023 +0200 update PTME code commit 097be17a2900e64021fcbb457c89d6d4756ab697 Author: meggert Date: Wed Apr 19 15:07:21 2023 +0200 added remaining acs modes as system modes --- CHANGELOG.md | 11 +++++++++ bsp_q7s/boardconfig/busConf.h | 6 ++--- bsp_q7s/core/ObjectFactory.cpp | 28 +++++++---------------- common/config/devices/gpioIds.h | 5 ---- linux/ipcore/PapbVcInterface.cpp | 39 +++++++++++++++----------------- linux/ipcore/PapbVcInterface.h | 11 ++++----- 6 files changed, 43 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..45bddbd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,16 @@ will consitute of a breaking change warranting a new major release: # [v2.2.0] to be released +TODO: New firmware package version. + +## Changed + +- Removed PTME busy/ready signals. Those were not used anyway because register reads are used now. + +## Fixed + +- Important bugfixes for PTME. See `q7s-package` CHANGELOG. + # [v2.1.0] to be released ## Changed @@ -49,6 +59,7 @@ will consitute of a breaking change warranting a new major release: # [v2.0.5] 2023-05-11 + - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 4fd15258..304113d2 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -82,14 +82,12 @@ static constexpr char EN_RW_4[] = "enable_rw_4"; static constexpr char RAD_SENSOR_CHIP_SELECT[] = "rad_sensor_chip_select"; static constexpr char ENABLE_RADFET[] = "enable_radfet"; -static constexpr char PAPB_BUSY_SIGNAL_VC0[] = "papb_busy_signal_vc0"; + static constexpr char PAPB_EMPTY_SIGNAL_VC0[] = "papb_empty_signal_vc0"; -static constexpr char PAPB_BUSY_SIGNAL_VC1[] = "papb_busy_signal_vc1"; static constexpr char PAPB_EMPTY_SIGNAL_VC1[] = "papb_empty_signal_vc1"; -static constexpr char PAPB_BUSY_SIGNAL_VC2[] = "papb_busy_signal_vc2"; static constexpr char PAPB_EMPTY_SIGNAL_VC2[] = "papb_empty_signal_vc2"; -static constexpr char PAPB_BUSY_SIGNAL_VC3[] = "papb_busy_signal_vc3"; static constexpr char PAPB_EMPTY_SIGNAL_VC3[] = "papb_empty_signal_vc3"; + static constexpr char PTME_RESETN[] = "ptme_resetn"; static constexpr char RS485_EN_TX_CLOCK[] = "tx_clock_enable_ltc2872"; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 12e9177f..24ea22f8 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -729,20 +729,12 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(CcsdsComponentArgs& args) { // GPIO definitions of signals connected to the virtual channel interfaces of the PTME IP Core GpioCookie* gpioCookiePtmeIp = new GpioCookie; GpiodRegularByLineName* gpio = nullptr; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC0, "PAPB VC0"); - gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC0, "PAPB VC0"); gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC1, "PAPB VC1"); - gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC1, "PAPB VC1"); gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC2, "PAPB VC2"); - gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC2, "PAPB VC2"); gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, gpio); - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC3, "PAPB VC3"); - gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, "PAPB VC3"); gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); gpio = new GpiodRegularByLineName(q7s::gpioNames::PTME_RESETN, "PTME RESETN", @@ -751,18 +743,14 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(CcsdsComponentArgs& args) { gpioChecker(args.gpioComIF.addGpios(gpioCookiePtmeIp), "PTME PAPB VCs"); // Creating virtual channel interfaces - VirtualChannelIF* vc0 = - new PapbVcInterface(&args.gpioComIF, gpioIds::VC0_PAPB_BUSY, gpioIds::VC0_PAPB_EMPTY, - q7s::UIO_PTME, q7s::uiomapids::PTME_VC0); - VirtualChannelIF* vc1 = - new PapbVcInterface(&args.gpioComIF, gpioIds::VC1_PAPB_BUSY, gpioIds::VC1_PAPB_EMPTY, - q7s::UIO_PTME, q7s::uiomapids::PTME_VC1); - VirtualChannelIF* vc2 = - new PapbVcInterface(&args.gpioComIF, gpioIds::VC2_PAPB_BUSY, gpioIds::VC2_PAPB_EMPTY, - q7s::UIO_PTME, q7s::uiomapids::PTME_VC2); - VirtualChannelIF* vc3 = - new PapbVcInterface(&args.gpioComIF, gpioIds::VC3_PAPB_BUSY, gpioIds::VC3_PAPB_EMPTY, - q7s::UIO_PTME, q7s::uiomapids::PTME_VC3); + VirtualChannelIF* vc0 = new PapbVcInterface(&args.gpioComIF, gpioIds::VC0_PAPB_EMPTY, + q7s::UIO_PTME, q7s::uiomapids::PTME_VC0); + VirtualChannelIF* vc1 = new PapbVcInterface(&args.gpioComIF, gpioIds::VC1_PAPB_EMPTY, + q7s::UIO_PTME, q7s::uiomapids::PTME_VC1); + VirtualChannelIF* vc2 = new PapbVcInterface(&args.gpioComIF, gpioIds::VC2_PAPB_EMPTY, + q7s::UIO_PTME, q7s::uiomapids::PTME_VC2); + VirtualChannelIF* vc3 = new PapbVcInterface(&args.gpioComIF, gpioIds::VC3_PAPB_EMPTY, + q7s::UIO_PTME, q7s::uiomapids::PTME_VC3); // Creating ptme object and adding virtual channel interfaces Ptme* ptme = new Ptme(objects::PTME); ptme->addVcInterface(ccsds::VC0, vc0); diff --git a/common/config/devices/gpioIds.h b/common/config/devices/gpioIds.h index 640f4ead..573327fa 100644 --- a/common/config/devices/gpioIds.h +++ b/common/config/devices/gpioIds.h @@ -93,15 +93,10 @@ enum gpioId_t { EN_RW_CS, SPI_MUX, - VC0_PAPB_EMPTY, - VC0_PAPB_BUSY, VC1_PAPB_EMPTY, - VC1_PAPB_BUSY, VC2_PAPB_EMPTY, - VC2_PAPB_BUSY, VC3_PAPB_EMPTY, - VC3_PAPB_BUSY, PTME_RESETN, PDEC_RESET, diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 60968cc6..7a1a89e4 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -7,13 +7,9 @@ #include "fsfw/serviceinterface/ServiceInterface.h" -PapbVcInterface::PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, std::string uioFile, int mapNum) - : gpioComIF(gpioComIF), - papbBusyId(papbBusyId), - papbEmptyId(papbEmptyId), - uioFile(std::move(uioFile)), - mapNum(mapNum) {} +PapbVcInterface::PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbEmptyId, + std::string uioFile, int mapNum) + : gpioComIF(gpioComIF), papbEmptyId(papbEmptyId), uioFile(std::move(uioFile)), mapNum(mapNum) {} PapbVcInterface::~PapbVcInterface() {} @@ -99,7 +95,7 @@ void PapbVcInterface::startPacketTransfer(ByteWidthCfg initWidth) { void PapbVcInterface::completePacketTransfer() { *vcBaseReg = CONFIG_END; } ReturnValue_t PapbVcInterface::pollInterfaceReadiness(uint32_t maxPollRetries, - bool checkReadyState) const { + bool checkReadyForPacketState) const { uint32_t busyIdx = 0; nextDelay.tv_nsec = FIRST_DELAY_PAPB_POLLING_NS; @@ -108,13 +104,16 @@ ReturnValue_t PapbVcInterface::pollInterfaceReadiness(uint32_t maxPollRetries, // Bit 5, see PTME ptme_001_01-0-7-r2 Table 31. uint32_t reg = *vcBaseReg; bool busy = (reg >> 5) & 0b1; - bool ready = (reg >> 6) & 0b1; - if (not busy) { + bool readyForPacket = (reg >> 6) & 0b1; + if (checkReadyForPacketState) { + if (not busy and readyForPacket) { + return returnvalue::OK; + } else if (not busy and not readyForPacket) { + return PAPB_BUSY; + } + } else if (not busy) { return returnvalue::OK; } - if (checkReadyState and not ready) { - return PAPB_BUSY; - } busyIdx++; if (busyIdx >= maxPollRetries) { @@ -131,24 +130,22 @@ ReturnValue_t PapbVcInterface::pollInterfaceReadiness(uint32_t maxPollRetries, return returnvalue::OK; } -void PapbVcInterface::isVcInterfaceBufferEmpty() { +bool PapbVcInterface::isVcInterfaceBufferEmpty() { ReturnValue_t result = returnvalue::OK; gpio::Levels papbEmptyState = gpio::Levels::HIGH; result = gpioComIF->readGpio(papbEmptyId, papbEmptyState); if (result != returnvalue::OK) { - sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; + sif::error << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + << std::endl; + return true; } if (papbEmptyState == gpio::Levels::HIGH) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; - } else { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; + return true; } - return; + return false; } bool PapbVcInterface::isBusy() const { return pollInterfaceReadiness(0, true) == PAPB_BUSY; } diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index e54def5d..71dd143b 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -30,8 +30,7 @@ class PapbVcInterface : public VirtualChannelIF { * @param uioFile UIO file providing access to the PAPB bus * @param mapNum Map number of UIO map associated with this virtual channel */ - PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, gpioId_t papbEmptyId, - std::string uioFile, int mapNum); + PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbEmptyId, std::string uioFile, int mapNum); virtual ~PapbVcInterface(); bool isBusy() const override; @@ -83,9 +82,6 @@ class PapbVcInterface : public VirtualChannelIF { static constexpr long int MAX_DELAY_PAPB_POLLING_NS = 40; LinuxLibgpioIF* gpioComIF = nullptr; - - /** Pulled to low when virtual channel not ready to receive data */ - gpioId_t papbBusyId = gpio::NO_GPIO; /** High when external buffer memory of virtual channel is empty */ gpioId_t papbEmptyId = gpio::NO_GPIO; @@ -120,13 +116,14 @@ class PapbVcInterface : public VirtualChannelIF { * * @return returnvalue::OK when ready to receive data else PAPB_BUSY. */ - inline ReturnValue_t pollInterfaceReadiness(uint32_t maxPollRetries, bool checkReadyState) const; + inline ReturnValue_t pollInterfaceReadiness(uint32_t maxPollRetries, + bool checkReadyForPacketState) const; /** * @brief This function can be used for debugging to check whether there are packets in * the packet buffer of the virtual channel or not. */ - void isVcInterfaceBufferEmpty(); + bool isVcInterfaceBufferEmpty(); /** * @brief This function sends a complete telemetry transfer frame data field (1105 bytes) From 770697d5d06f55dfd0e293c88d45d86e5e59b366 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 10:16:34 +0200 Subject: [PATCH 037/172] forgot some git merge conflicts --- linux/payload/plocMpscoDefs.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 3d74fe0d..27bef077 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -127,10 +127,7 @@ static const uint16_t ACK_FAILURE = 0x401; static const uint16_t EXE_SUCCESS = 0x402; static const uint16_t EXE_FAILURE = 0x403; static const uint16_t TM_MEMORY_READ_REPORT = 0x404; -<<<<<<< HEAD static const uint16_t TM_FLASH_READ_REPORT = 0x405; -======= ->>>>>>> origin/v2.1.0-dev static constexpr uint16_t TM_FLASH_DIRECTORY_CONTENT = 0x406; static const uint16_t TM_CAM_CMD_RPT = 0x407; static constexpr uint16_t TM_HK_GET_REPORT = 0x408; @@ -675,21 +672,13 @@ class TcGetDirContent : public TcBase { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; -<<<<<<< HEAD - spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE); -======= // Yeah it needs to be 256.. even if the path is shorter. spParams.setFullPayloadLen(256 + CRC_SIZE); ->>>>>>> origin/v2.1.0-dev if (result != returnvalue::OK) { return result; } std::memcpy(payloadStart, commandData, commandDataLen); -<<<<<<< HEAD - *(payloadStart + commandDataLen) = NULL_TERMINATOR; -======= payloadStart[255] = '\0'; ->>>>>>> origin/v2.1.0-dev return result; } }; From 9fde16c9125338b7967d5d876b8a2f3a176168ea Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 10:29:15 +0200 Subject: [PATCH 038/172] disable missed deadline printing by default --- bsp_q7s/OBSWConfig.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index 51ed8828..1c0a4db8 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -72,7 +72,7 @@ // Can be used to switch device to NORMAL mode immediately #define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 0 -#define OBSW_PRINT_MISSED_DEADLINES 1 +#define OBSW_PRINT_MISSED_DEADLINES 0 #define OBSW_MPSOC_JTAG_BOOT 0 #define OBSW_STAR_TRACKER_GROUND_CONFIG @OBSW_STAR_TRACKER_GROUND_CONFIG@ From f099cd7688cfe028a6f3463cb89916e586a73241 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 13:25:53 +0200 Subject: [PATCH 039/172] seems to work fine --- linux/payload/PlocMpsocHandler.cpp | 44 +++++++++++++++++++----------- linux/payload/PlocMpsocHandler.h | 8 ++++-- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 0c2ce279..a8634f6a 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -79,6 +79,11 @@ ReturnValue_t PlocMPSoCHandler::initialize() { } void PlocMPSoCHandler::performOperationHook() { + if (commandIsPending and cmdCountdown.hasTimedOut()) { + commandIsPending = false; + // TODO: Better returnvalue? + cmdDoneHandler(false, returnvalue::FAILED); + } EventMessage event; for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK; result = eventQueue->receiveMessage(&event)) { @@ -106,6 +111,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI const uint8_t* data, size_t size) { ReturnValue_t result = returnvalue::OK; commandIsPending = true; + cmdCountdown.resetTimer(); switch (actionId) { case mpsoc::SET_UART_TX_TRISTATE: { uartIsolatorSwitch.pullLow(); @@ -242,6 +248,7 @@ ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) if (not commandIsPending) { *id = mpsoc::TC_GET_HK_REPORT; commandIsPending = true; + cmdCountdown.resetTimer(); return buildCommandFromCommand(*id, nullptr, 0); } return NOTHING_TO_SEND; @@ -439,6 +446,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain } // This sequence count ping pong does not make any sense but it is how the MPSoC expects it. sequenceCount++; + return result; } @@ -817,23 +825,9 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - auto cmdDoneHandler = [&](bool success) { - if (normalCmdPending) { - normalCmdPending = false; - } - commandIsPending = false; - auto commandIter = deviceCommandMap.find(getPendingCommand()); - if (commandIter != deviceCommandMap.end()) { - commandIter->second.isExecuting = false; - if (commandIter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) { - actionHelper.finish(success, commandIter->second.sendReplyTo, getPendingCommand(), result); - } - } - disableAllReplies(); - }; switch (apid) { case (mpsoc::apid::EXE_SUCCESS): { - cmdDoneHandler(true); + cmdDoneHandler(true, result); break; } case (mpsoc::apid::EXE_FAILURE): { @@ -850,7 +844,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { printStatus(data); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); result = IGNORE_REPLY_DATA; - cmdDoneHandler(false); + cmdDoneHandler(false, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); break; } default: { @@ -1482,6 +1476,24 @@ LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) { return nullptr; } +bool PlocMPSoCHandler::dontCheckQueue() { + // The TC and TMs need to be handled strictly sequentially, so while a command is pending, + // more specifically while replies are still expected, do not check the queue.s + return commandIsPending; +} + +void PlocMPSoCHandler::cmdDoneHandler(bool success, ReturnValue_t result) { + commandIsPending = false; + auto commandIter = deviceCommandMap.find(getPendingCommand()); + if (commandIter != deviceCommandMap.end()) { + commandIter->second.isExecuting = false; + if (commandIter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) { + actionHelper.finish(success, commandIter->second.sendReplyTo, getPendingCommand(), result); + } + } + disableAllReplies(); +} + std::string PlocMPSoCHandler::getStatusString(uint16_t status) { switch (status) { case (mpsoc::status_code::UNKNOWN_APID): { diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index a6af8156..2a16d9fe 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -28,7 +28,8 @@ * @note The sequence count in the space packets must be incremented with each received and sent * packet otherwise the MPSoC will reply with an acknowledgment failure report. * - * @author J. Meier + * NOTE: This is not an example for a good device handler, DO NOT USE THIS AS A REFERENCE HANDLER. + * @author J. Meier, R. Mueller */ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { public: @@ -79,6 +80,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; ReturnValue_t doSendReadHook() override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + bool dontCheckQueue() override; private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; @@ -108,7 +110,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { mpsoc::HkReport hkReport; - bool normalCmdPending = false; MessageQueueIF* eventQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr; @@ -177,6 +178,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { }; TmMemReadReport tmMemReadReport; + Countdown cmdCountdown = Countdown(10000); struct TelemetryBuffer { uint16_t length = 0; @@ -301,6 +303,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { uint16_t getStatus(const uint8_t* data); + void cmdDoneHandler(bool success, ReturnValue_t result); + void handleActionCommandFailure(ActionId_t actionId); std::string getStatusString(uint16_t status); From ae6b5b491b7d7bb54269f01739e5d0a3d4245f93 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 13:27:24 +0200 Subject: [PATCH 040/172] that should get the job done --- linux/payload/PlocMpsocHandler.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index a8634f6a..dacc423f 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -110,8 +110,6 @@ void PlocMPSoCHandler::performOperationHook() { ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { ReturnValue_t result = returnvalue::OK; - commandIsPending = true; - cmdCountdown.resetTimer(); switch (actionId) { case mpsoc::SET_UART_TX_TRISTATE: { uartIsolatorSwitch.pullLow(); @@ -169,6 +167,9 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI default: break; } + // For longer commands, do not set these. + commandIsPending = true; + cmdCountdown.resetTimer(); return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } @@ -245,7 +246,7 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if (not commandIsPending) { + if (not commandIsPending and not plocMPSoCHelperExecuting) { *id = mpsoc::TC_GET_HK_REPORT; commandIsPending = true; cmdCountdown.resetTimer(); From 178a2183a2acc2e2fb3d9e5e4edb54201cb21529 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 14:40:14 +0200 Subject: [PATCH 041/172] clean up error handlng code --- bsp_q7s/core/scheduling.cpp | 4 +- linux/payload/PlocMpsocHandler.cpp | 108 +++-------------------------- linux/payload/PlocMpsocHandler.h | 4 -- linux/payload/PlocMpsocHelper.cpp | 30 +++++--- linux/payload/PlocMpsocHelper.h | 2 +- linux/payload/plocMpscoDefs.h | 87 +++++++++++++++++++++++ tmtc | 2 +- 7 files changed, 121 insertions(+), 116 deletions(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index 5866ce8c..71da5bdc 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -345,7 +345,6 @@ void scheduling::initTasks() { } #endif /* OBSW_ADD_STAR_TRACKER == 1 */ - // TODO: Use regular scheduler for this task #if OBSW_ADD_PLOC_MPSOC == 1 PeriodicTaskIF* mpsocHelperTask = factory->createPeriodicTask( "PLOC_MPSOC_HELPER", 0, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); @@ -472,6 +471,9 @@ void scheduling::initTasks() { #if OBSW_ADD_PLOC_SUPERVISOR == 1 supvHelperTask->startTask(); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ +#if OBSW_ADD_PLOC_MPSOC == 1 + mpsocHelperTask->startTask(); +#endif plTask->startTask(); #if OBSW_ADD_TEST_CODE == 1 diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index dacc423f..68dccd86 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -136,6 +136,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } + plocMPSoCHelper->setSequenceCount(&sequenceCount); result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(), flashWritePusCmd.getMPSoCFile()); if (result != returnvalue::OK) { @@ -150,6 +151,9 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } + sif::debug << "starting flash read" << std::endl; + sif::debug << "sequence count: " << sequenceCount.get() << std::endl; + plocMPSoCHelper->setSequenceCount(&sequenceCount); result = plocMPSoCHelper->startFlashRead(flashReadPusCmd.getObcFile(), flashReadPusCmd.getMPSoCFile(), flashReadPusCmd.getReadSize()); @@ -158,7 +162,6 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI } plocMPSoCHelperExecuting = true; return EXECUTION_FINISHED; - break; } case (mpsoc::OBSW_RESET_SEQ_COUNT): { sequenceCount = 0; @@ -790,7 +793,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; DeviceCommandId_t commandId = getPendingCommand(); uint16_t status = getStatus(data); - printStatus(data); + sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(ACK_FAILURE, commandId, status); } @@ -836,13 +839,12 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" << std::endl; DeviceCommandId_t commandId = getPendingCommand(); - if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { - uint16_t status = getStatus(data); - triggerEvent(EXE_FAILURE, commandId, status); - } else { + if (commandId == DeviceHandlerIF::NO_COMMAND_ID) { sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; } - printStatus(data); + uint16_t status = getStatus(data); + sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; + triggerEvent(EXE_FAILURE, commandId, status); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); result = IGNORE_REPLY_DATA; cmdDoneHandler(false, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); @@ -1428,11 +1430,6 @@ void PlocMPSoCHandler::disableExeReportReply() { info->command->second.expectedReplies = 0; } -void PlocMPSoCHandler::printStatus(const uint8_t* data) { - uint16_t status = (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); - sif::info << "Verification report status: " << getStatusString(status) << std::endl; -} - uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); } @@ -1494,90 +1491,3 @@ void PlocMPSoCHandler::cmdDoneHandler(bool success, ReturnValue_t result) { } disableAllReplies(); } - -std::string PlocMPSoCHandler::getStatusString(uint16_t status) { - switch (status) { - case (mpsoc::status_code::UNKNOWN_APID): { - return "Unknown APID"; - break; - } - case (mpsoc::status_code::INCORRECT_LENGTH): { - return "Incorrect length"; - break; - } - case (mpsoc::status_code::INCORRECT_CRC): { - return "Incorrect crc"; - break; - } - case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): { - return "Incorrect packet sequence count"; - break; - } - case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): { - return "TC not allowed in this mode"; - break; - } - case (mpsoc::status_code::TC_EXEUTION_DISABLED): { - return "TC execution disabled"; - break; - } - case (mpsoc::status_code::FLASH_MOUNT_FAILED): { - return "Flash mount failed"; - break; - } - case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): { - return "Flash file already closed"; - break; - } - case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): { - return "Flash file open failed"; - break; - } - case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): { - return "Flash file not open"; - break; - } - case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): { - return "Flash unmount failed"; - break; - } - case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): { - return "Heap allocation failed"; - break; - } - case (mpsoc::status_code::INVALID_PARAMETER): { - return "Invalid parameter"; - break; - } - case (mpsoc::status_code::NOT_INITIALIZED): { - return "Not initialized"; - break; - } - case (mpsoc::status_code::REBOOT_IMMINENT): { - return "Reboot imminent"; - break; - } - case (mpsoc::status_code::CORRUPT_DATA): { - return "Corrupt data"; - break; - } - case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): { - return "Flash correctable mismatch"; - break; - } - case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): { - return "Flash uncorrectable mismatch"; - break; - } - case (mpsoc::status_code::DEFAULT_ERROR_CODE): { - return "Default error code"; - break; - } - default: - std::stringstream ss; - ss << "0x" << std::hex << status; - return ss.str(); - break; - } - return ""; -} diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 2a16d9fe..dc6ebd99 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -297,8 +297,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { */ void disableExeReportReply(); - void printStatus(const uint8_t* data); - ReturnValue_t prepareTcModeReplay(); uint16_t getStatus(const uint8_t* data); @@ -306,8 +304,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { void cmdDoneHandler(bool success, ReturnValue_t result); void handleActionCommandFailure(ActionId_t actionId); - - std::string getStatusString(uint16_t status); }; #endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */ diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocHelper.cpp index 421ac83c..66e46c18 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocHelper.cpp @@ -38,6 +38,7 @@ ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { #endif switch (internalState) { case InternalState::IDLE: { + sif::debug << "ploc mpsoc helper idle" << std::endl; semaphore.acquire(); break; } @@ -84,32 +85,35 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { } ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { + if (internalState != InternalState::IDLE) { + return returnvalue::FAILED; + } ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile)); if (result != returnvalue::OK) { return result; } internalState = InternalState::FLASH_WRITE; - return result; + return semaphore.release(); } ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, size_t readFileSize) { + if (internalState != InternalState::IDLE) { + return returnvalue::FAILED; + } ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile)); if (result != returnvalue::OK) { return result; } flashReadAndWrite.totalReadSize = readFileSize; internalState = InternalState::FLASH_READ; - return result; + return semaphore.release(); } -ReturnValue_t PlocMPSoCHelper::resetHelper() { - ReturnValue_t result = returnvalue::OK; - semaphore.release(); +void PlocMPSoCHelper::resetHelper() { spParams.buf = commandBuffer; terminate = false; - result = uartComIF->flushUartRxBuffer(comCookie); - return result; + uartComIF->flushUartRxBuffer(comCookie); } void PlocMPSoCHelper::stopProcess() { terminate = true; } @@ -169,11 +173,13 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { } ReturnValue_t PlocMPSoCHelper::performFlashRead() { + sif::debug << "performing flash read" << std::endl; std::error_code e; std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary); if (ofile.bad()) { return returnvalue::FAILED; } + sif::debug << "Sequence count: " << sequenceCount->get() << std::endl; ReturnValue_t result = flashfopen(); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); @@ -191,11 +197,13 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() { if (flashReadAndWrite.totalReadSize - readSoFar < mpsoc::MAX_FLASH_READ_DATA_SIZE) { nextReadSize = flashReadAndWrite.totalReadSize - readSoFar; } + sif::debug << "reading " << nextReadSize << " bytes from offset " << readSoFar << std::endl; if (ofile.bad() or not ofile.is_open()) { std::filesystem::remove(flashReadAndWrite.obcFile, e); flashfclose(); return FILE_READ_ERROR; } + (*sequenceCount)++; mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); result = flashReadRequest.buildPacket(nextReadSize); if (result != returnvalue::OK) { @@ -215,9 +223,9 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() { flashfclose(); return result; } - (*sequenceCount)++; readSoFar += nextReadSize; } + sif::debug << "read file done" << std::endl; return result; } @@ -439,7 +447,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, flashReadAndWrite.obcFile = std::move(obcFile); flashReadAndWrite.mpsocFile = std::move(mpsocFile); - return resetHelper(); + resetHelper(); + return returnvalue::OK; } ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { @@ -456,12 +465,13 @@ ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount); return result; } - (*sequenceCount)++; uint16_t recvSeqCnt = reader.getSequenceCount(); if (recvSeqCnt != *sequenceCount) { triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt); *sequenceCount = recvSeqCnt; } + // This sequence count ping pong does not make any sense but it is how the MPSoC expects it. + (*sequenceCount)++; return returnvalue::OK; } diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocHelper.h index 63a40d0c..2595c811 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocHelper.h @@ -172,7 +172,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { // Sequence count, must be set by Ploc MPSoC Handler SourceSequenceCounter* sequenceCount = nullptr; - ReturnValue_t resetHelper(); + void resetHelper(); ReturnValue_t performFlashWrite(); ReturnValue_t performFlashRead(); ReturnValue_t flashfopen(); diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 27bef077..4bb19e4d 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -989,6 +989,93 @@ class HkReport : public StaticLocalDataSet<36> { lp_var_t(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this); }; +const char* getStatusString(uint16_t status) { + switch (status) { + case (mpsoc::status_code::UNKNOWN_APID): { + return "Unknown APID"; + break; + } + case (mpsoc::status_code::INCORRECT_LENGTH): { + return "Incorrect length"; + break; + } + case (mpsoc::status_code::INCORRECT_CRC): { + return "Incorrect crc"; + break; + } + case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): { + return "Incorrect packet sequence count"; + break; + } + case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): { + return "TC not allowed in this mode"; + break; + } + case (mpsoc::status_code::TC_EXEUTION_DISABLED): { + return "TC execution disabled"; + break; + } + case (mpsoc::status_code::FLASH_MOUNT_FAILED): { + return "Flash mount failed"; + break; + } + case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): { + return "Flash file already closed"; + break; + } + case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): { + return "Flash file open failed"; + break; + } + case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): { + return "Flash file not open"; + break; + } + case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): { + return "Flash unmount failed"; + break; + } + case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): { + return "Heap allocation failed"; + break; + } + case (mpsoc::status_code::INVALID_PARAMETER): { + return "Invalid parameter"; + break; + } + case (mpsoc::status_code::NOT_INITIALIZED): { + return "Not initialized"; + break; + } + case (mpsoc::status_code::REBOOT_IMMINENT): { + return "Reboot imminent"; + break; + } + case (mpsoc::status_code::CORRUPT_DATA): { + return "Corrupt data"; + break; + } + case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): { + return "Flash correctable mismatch"; + break; + } + case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): { + return "Flash uncorrectable mismatch"; + break; + } + case (mpsoc::status_code::DEFAULT_ERROR_CODE): { + return "Default error code"; + break; + } + default: + std::stringstream ss; + ss << "0x" << std::hex << status; + return ss.str(); + break; + } + return ""; +} + } // namespace mpsoc #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/tmtc b/tmtc index dd3e4c64..280c7243 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit dd3e4c649b687ea6b9444389439f3f2d5a558ad2 +Subproject commit 280c72439effa1b4290dc500dade2c62a9d6e3f7 From 17df79b0d60a052f07b636abc7b9c9e8286063c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 15:15:58 +0200 Subject: [PATCH 042/172] this does not make sense --- bsp_q7s/core/ObjectFactory.cpp | 8 +- linux/payload/CMakeLists.txt | 3 +- linux/payload/PlocMpsocHandler.cpp | 132 +++++++++--------- linux/payload/PlocMpsocHandler.h | 17 +-- ...lper.cpp => PlocMpsocSpecialComHelper.cpp} | 89 ++++++------ ...ocHelper.h => PlocMpsocSpecialComHelper.h} | 14 +- linux/payload/plocMpsocHelpers.cpp | 91 ++++++++++++ .../{plocMpscoDefs.h => plocMpsocHelpers.h} | 117 +++------------- 8 files changed, 243 insertions(+), 228 deletions(-) rename linux/payload/{PlocMpsocHelper.cpp => PlocMpsocSpecialComHelper.cpp} (81%) rename linux/payload/{PlocMpsocHelper.h => PlocMpsocSpecialComHelper.h} (95%) create mode 100644 linux/payload/plocMpsocHelpers.cpp rename linux/payload/{plocMpscoDefs.h => plocMpsocHelpers.h} (92%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 8fcace4e..17b14b56 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -10,10 +10,10 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include #include @@ -623,8 +623,8 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV, serial::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); mpsocCookie->setNoFixedSizeReply(); - auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); - auto* mpsocHandler = new PlocMPSoCHandler( + auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER); + auto* mpsocHandler = new PlocMpsocHandler( objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), objects::PLOC_SUPERVISOR_HANDLER); mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); diff --git a/linux/payload/CMakeLists.txt b/linux/payload/CMakeLists.txt index 7b2c4486..e697fac6 100644 --- a/linux/payload/CMakeLists.txt +++ b/linux/payload/CMakeLists.txt @@ -2,7 +2,8 @@ target_sources( ${OBSW_NAME} PUBLIC PlocMemoryDumper.cpp PlocMpsocHandler.cpp - PlocMpsocHelper.cpp + PlocMpsocSpecialComHelper.cpp + plocMpsocHelpers.cpp PlocSupervisorHandler.cpp PlocSupvUartMan.cpp ScexDleParser.cpp diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 68dccd86..a07c7871 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -8,8 +8,8 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/globalfunctions/CRC.h" -PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, - CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, +PlocMpsocHandler::PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid, + CookieIF* comCookie, PlocMpsocSpecialComHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, object_id_t supervisorHandler) : DeviceHandlerBase(objectId, uartComIFid, comCookie), hkReport(this), @@ -27,9 +27,9 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid spParams.buf = commandBuffer; } -PlocMPSoCHandler::~PlocMPSoCHandler() {} +PlocMpsocHandler::~PlocMpsocHandler() {} -ReturnValue_t PlocMPSoCHandler::initialize() { +ReturnValue_t PlocMpsocHandler::initialize() { ReturnValue_t result = returnvalue::OK; result = DeviceHandlerBase::initialize(); if (result != returnvalue::OK) { @@ -54,8 +54,8 @@ ReturnValue_t PlocMPSoCHandler::initialize() { return result; } result = manager->subscribeToEventRange( - eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED), - event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL)); + eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_FAILED), + event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_SUCCESSFUL)); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from " @@ -78,7 +78,7 @@ ReturnValue_t PlocMPSoCHandler::initialize() { return result; } -void PlocMPSoCHandler::performOperationHook() { +void PlocMpsocHandler::performOperationHook() { if (commandIsPending and cmdCountdown.hasTimedOut()) { commandIsPending = false; // TODO: Better returnvalue? @@ -107,7 +107,7 @@ void PlocMPSoCHandler::performOperationHook() { } } -ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, +ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { ReturnValue_t result = returnvalue::OK; switch (actionId) { @@ -176,7 +176,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); } -void PlocMPSoCHandler::doStartUp() { +void PlocMpsocHandler::doStartUp() { if (startupState == StartupState::IDLE) { startupState = StartupState::HW_INIT; } @@ -220,7 +220,7 @@ void PlocMPSoCHandler::doStartUp() { } } -void PlocMPSoCHandler::doShutDown() { +void PlocMpsocHandler::doShutDown() { #ifdef XIPHOS_Q7S #if not OBSW_MPSOC_JTAG_BOOT == 1 switch (powerState) { @@ -248,7 +248,7 @@ void PlocMPSoCHandler::doShutDown() { startupState = StartupState::IDLE; } -ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { +ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { if (not commandIsPending and not plocMPSoCHelperExecuting) { *id = mpsoc::TC_GET_HK_REPORT; commandIsPending = true; @@ -258,11 +258,11 @@ ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) return NOTHING_TO_SEND; } -ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { +ReturnValue_t PlocMpsocHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return NOTHING_TO_SEND; } -ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, +ReturnValue_t PlocMpsocHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { spParams.buf = commandBuffer; @@ -353,7 +353,7 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device return result; } -void PlocMPSoCHandler::fillCommandAndReplyMap() { +void PlocMpsocHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::TC_MEM_WRITE); this->insertInCommandMap(mpsoc::TC_MEM_READ); this->insertInCommandMap(mpsoc::TC_FLASHDELETE); @@ -383,7 +383,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE); } -ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, +ReturnValue_t PlocMpsocHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = returnvalue::OK; @@ -454,7 +454,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain return result; } -ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { +ReturnValue_t PlocMpsocHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { ReturnValue_t result = returnvalue::OK; switch (id) { @@ -499,14 +499,14 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { +void PlocMpsocHandler::setNormalDatapoolEntriesInvalid() { PoolReadGuard pg(&hkReport); hkReport.setValidity(false, true); } -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; } +uint32_t PlocMpsocHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; } -ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, +ReturnValue_t PlocMpsocHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus); localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); @@ -547,7 +547,7 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc return returnvalue::OK; } -void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) { +void PlocMpsocHandler::handleEvent(EventMessage* eventMessage) { object_id_t objectId = eventMessage->getReporter(); switch (objectId) { case objects::PLOC_MPSOC_HELPER: { @@ -560,7 +560,7 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) { } } -ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcMemWrite(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount); @@ -572,7 +572,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcMemRead tcMemRead(spParams, sequenceCount); @@ -585,7 +585,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { return MPSoCReturnValuesIF::NAME_TOO_LONG; @@ -601,7 +601,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount); @@ -613,7 +613,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() { +ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount); result = tcReplayStop.buildPacket(); @@ -624,7 +624,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount); @@ -636,7 +636,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { +ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() { ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount); result = tcDownlinkPwrOff.buildPacket(); @@ -647,7 +647,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { +ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() { mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount); ReturnValue_t result = tcGetHkReport.buildPacket(); if (result != returnvalue::OK) { @@ -657,7 +657,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount); @@ -669,7 +669,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() { +ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() { ReturnValue_t result = returnvalue::OK; mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount); result = tcModeReplay.buildPacket(); @@ -680,7 +680,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() { +ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() { ReturnValue_t result = returnvalue::OK; mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount); result = tcModeIdle.buildPacket(); @@ -691,7 +691,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount); @@ -704,7 +704,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen); @@ -715,7 +715,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); @@ -726,7 +726,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandD return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount); ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen); @@ -737,7 +737,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandDat return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, +ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); @@ -748,7 +748,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { +ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() { mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); ReturnValue_t result = tcModeSnapshot.buildPacket(); if (result != returnvalue::OK) { @@ -758,21 +758,21 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { return returnvalue::OK; } -void PlocMPSoCHandler::finishTcPrep(size_t packetLen) { +void PlocMpsocHandler::finishTcPrep(size_t packetLen) { nextReplyId = mpsoc::ACK_REPORT; rawPacket = commandBuffer; rawPacketLen = packetLen; sequenceCount++; } -ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { +ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) { if (CRC::crc16ccitt(start, foundLen) != 0) { return MPSoCReturnValuesIF::CRC_FAILURE; } return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleAckReport(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT); @@ -792,7 +792,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { case mpsoc::apid::ACK_FAILURE: { sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; DeviceCommandId_t commandId = getPendingCommand(); - uint16_t status = getStatus(data); + uint16_t status = mpsoc::getStatusFromRawData(data); sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(ACK_FAILURE, commandId, status); @@ -817,7 +817,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT); @@ -842,7 +842,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { if (commandId == DeviceHandlerIF::NO_COMMAND_ID) { sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; } - uint16_t status = getStatus(data); + uint16_t status = mpsoc::getStatusFromRawData(data); sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; triggerEvent(EXE_FAILURE, commandId, status); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); @@ -860,7 +860,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleMemoryReadReport(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; result = verifyPacket(data, tmMemReadReport.rememberRequestedSize); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { @@ -876,7 +876,7 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleGetHkReport(const uint8_t* data) { ReturnValue_t result = verifyPacket(data, foundPacketLen); if (result != returnvalue::OK) { return result; @@ -1054,7 +1054,7 @@ ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { +ReturnValue_t PlocMpsocHandler::handleCamCmdRpt(const uint8_t* data) { ReturnValue_t result = verifyPacket(data, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; @@ -1074,7 +1074,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { return result; } -ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, +ReturnValue_t PlocMpsocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, uint8_t expectedReplies, bool useAlternateId, DeviceCommandId_t alternateReplyID) { ReturnValue_t result = returnvalue::OK; @@ -1190,7 +1190,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator return returnvalue::OK; } -void PlocMPSoCHandler::setNextReplyId() { +void PlocMpsocHandler::setNextReplyId() { switch (getPendingCommand()) { case mpsoc::TC_MEM_READ: nextReplyId = mpsoc::TM_MEMORY_READ_REPORT; @@ -1210,7 +1210,7 @@ void PlocMPSoCHandler::setNextReplyId() { } } -size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { +size_t PlocMpsocHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t replyLen = 0; if (nextReplyId == mpsoc::NONE) { @@ -1251,7 +1251,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { return replyLen; } -ReturnValue_t PlocMPSoCHandler::doSendReadHook() { +ReturnValue_t PlocMpsocHandler::doSendReadHook() { // Prevent DHB from polling UART during commands executed by the mpsoc helper task if (plocMPSoCHelperExecuting) { return returnvalue::FAILED; @@ -1259,11 +1259,11 @@ ReturnValue_t PlocMPSoCHandler::doSendReadHook() { return returnvalue::OK; } -MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; } +MessageQueueIF* PlocMpsocHandler::getCommandQueuePtr() { return commandActionHelperQueue; } -void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; } +void PlocMpsocHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; } -void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, +void PlocMpsocHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, ReturnValue_t returnCode) { switch (actionId) { case supv::START_MPSOC: { @@ -1286,11 +1286,11 @@ void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step, } } -void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { +void PlocMpsocHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) { return; } -void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { +void PlocMpsocHandler::completionSuccessfulReceived(ActionId_t actionId) { if (actionId != supv::EXE_REPORT) { sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action " << "ID" << std::endl; @@ -1311,11 +1311,11 @@ void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) { } } -void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { +void PlocMpsocHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) { handleActionCommandFailure(actionId); } -void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, +void PlocMpsocHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { ReturnValue_t result = returnvalue::OK; @@ -1341,7 +1341,7 @@ void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, } } -void PlocMPSoCHandler::disableAllReplies() { +void PlocMpsocHandler::disableAllReplies() { using namespace mpsoc; DeviceReplyMap::iterator iter; @@ -1404,7 +1404,7 @@ void PlocMPSoCHandler::disableAllReplies() { nextReplyId = mpsoc::NONE; } -void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { +void PlocMpsocHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { DeviceReplyIter iter = deviceReplyMap.find(replyId); if (iter == deviceReplyMap.end()) { sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; @@ -1421,7 +1421,7 @@ void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_ info->isExecuting = false; } -void PlocMPSoCHandler::disableExeReportReply() { +void PlocMpsocHandler::disableExeReportReply() { DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT); DeviceReplyInfo* info = &(iter->second); info->delayCycles = 0; @@ -1430,11 +1430,7 @@ void PlocMPSoCHandler::disableExeReportReply() { info->command->second.expectedReplies = 0; } -uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { - return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); -} - -void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { +void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) { switch (actionId) { case supv::ACK_REPORT: case supv::EXE_REPORT: @@ -1467,20 +1463,20 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { return; } -LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase* PlocMpsocHandler::getDataSetHandle(sid_t sid) { if (sid == hkReport.getSid()) { return &hkReport; } return nullptr; } -bool PlocMPSoCHandler::dontCheckQueue() { +bool PlocMpsocHandler::dontCheckQueue() { // The TC and TMs need to be handled strictly sequentially, so while a command is pending, // more specifically while replies are still expected, do not check the queue.s return commandIsPending; } -void PlocMPSoCHandler::cmdDoneHandler(bool success, ReturnValue_t result) { +void PlocMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) { commandIsPending = false; auto commandIter = deviceCommandMap.find(getPendingCommand()); if (commandIter != deviceCommandMap.end()) { diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index dc6ebd99..a42075d8 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -1,9 +1,9 @@ #ifndef BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ #define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ -#include +#include #include -#include +#include #include #include @@ -31,7 +31,7 @@ * NOTE: This is not an example for a good device handler, DO NOT USE THIS AS A REFERENCE HANDLER. * @author J. Meier, R. Mueller */ -class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { +class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { public: /** * @brief Constructor @@ -44,10 +44,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { * module in the programmable logic * @param supervisorHandler Object ID of the supervisor handler */ - PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, - PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, + PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie, + PlocMpsocSpecialComHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, object_id_t supervisorHandler); - virtual ~PlocMPSoCHandler(); + virtual ~PlocMpsocHandler(); virtual ReturnValue_t initialize() override; ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) override; @@ -106,7 +106,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { static const uint16_t APID_MASK = 0x7FF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - static const uint8_t STATUS_OFFSET = 10; mpsoc::HkReport hkReport; @@ -163,7 +162,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { SerialComIF* uartComIf = nullptr; - PlocMPSoCHelper* plocMPSoCHelper = nullptr; + PlocMpsocSpecialComHelper* plocMPSoCHelper = nullptr; Gpio uartIsolatorSwitch; object_id_t supervisorHandler = 0; CommandActionHelper commandActionHelper; @@ -299,8 +298,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcModeReplay(); - uint16_t getStatus(const uint8_t* data); - void cmdDoneHandler(bool success, ReturnValue_t result); void handleActionCommandFailure(ActionId_t actionId); diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp similarity index 81% rename from linux/payload/PlocMpsocHelper.cpp rename to linux/payload/PlocMpsocSpecialComHelper.cpp index 66e46c18..6bc338c6 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -11,14 +11,15 @@ using namespace ploc; -PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) { +PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId) + : SystemObject(objectId) { spParams.buf = commandBuffer; spParams.maxSize = sizeof(commandBuffer); } -PlocMPSoCHelper::~PlocMPSoCHelper() {} +PlocMpsocSpecialComHelper::~PlocMpsocSpecialComHelper() {} -ReturnValue_t PlocMPSoCHelper::initialize() { +ReturnValue_t PlocMpsocSpecialComHelper::initialize() { #ifdef XIPHOS_Q7S sdcMan = SdCardManager::instance(); if (sdcMan == nullptr) { @@ -29,7 +30,7 @@ ReturnValue_t PlocMPSoCHelper::initialize() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { +ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode) { ReturnValue_t result = returnvalue::OK; semaphore.acquire(); while (true) { @@ -69,7 +70,7 @@ ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) { } } -ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { +ReturnValue_t PlocMpsocSpecialComHelper::setComIF(DeviceCommunicationIF* communicationInterface_) { uartComIF = dynamic_cast(communicationInterface_); if (uartComIF == nullptr) { sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl; @@ -78,13 +79,14 @@ ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInte return returnvalue::OK; } -void PlocMPSoCHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } +void PlocMpsocSpecialComHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; } -void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { +void PlocMpsocSpecialComHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { sequenceCount = sequenceCount_; } -ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { +ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile, + std::string mpsocFile) { if (internalState != InternalState::IDLE) { return returnvalue::FAILED; } @@ -96,8 +98,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string return semaphore.release(); } -ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, - size_t readFileSize) { +ReturnValue_t PlocMpsocSpecialComHelper::startFlashRead(std::string obcFile, std::string mpsocFile, + size_t readFileSize) { if (internalState != InternalState::IDLE) { return returnvalue::FAILED; } @@ -110,21 +112,21 @@ ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string m return semaphore.release(); } -void PlocMPSoCHelper::resetHelper() { +void PlocMpsocSpecialComHelper::resetHelper() { spParams.buf = commandBuffer; terminate = false; uartComIF->flushUartRxBuffer(comCookie); } -void PlocMPSoCHelper::stopProcess() { terminate = true; } +void PlocMpsocSpecialComHelper::stopProcess() { terminate = true; } -ReturnValue_t PlocMPSoCHelper::performFlashWrite() { +ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { ReturnValue_t result = returnvalue::OK; std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary); if (file.bad()) { return returnvalue::FAILED; } - result = flashfopen(); + result = flashfopen(mpsoc::FileAccessMode::WRITE); if (result != returnvalue::OK) { return result; } @@ -172,7 +174,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() { return result; } -ReturnValue_t PlocMPSoCHelper::performFlashRead() { +ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { sif::debug << "performing flash read" << std::endl; std::error_code e; std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary); @@ -180,7 +182,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() { return returnvalue::FAILED; } sif::debug << "Sequence count: " << sequenceCount->get() << std::endl; - ReturnValue_t result = flashfopen(); + ReturnValue_t result = flashfopen(mpsoc::FileAccessMode::READ); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); return result; @@ -229,12 +231,11 @@ ReturnValue_t PlocMPSoCHelper::performFlashRead() { return result; } -ReturnValue_t PlocMPSoCHelper::flashfopen() { +ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) { spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); - ReturnValue_t result = - flashFopen.createPacket(flashReadAndWrite.mpsocFile, mpsoc::FlashFopen::APPEND); + ReturnValue_t result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mode); if (result != returnvalue::OK) { return result; } @@ -245,7 +246,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::flashfclose() { +ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() { spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); @@ -256,7 +257,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() { return handlePacketTransmissionNoReply(flashFclose); } -ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { ReturnValue_t result = sendCommand(tc); if (result != returnvalue::OK) { return result; @@ -273,7 +274,7 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashR return handleExe(); } -ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { ReturnValue_t result = sendCommand(tc); if (result != returnvalue::OK) { return result; @@ -285,7 +286,7 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& t return handleExe(); } -ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { @@ -296,7 +297,7 @@ ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) { return result; } -ReturnValue_t PlocMPSoCHelper::handleAck() { +ReturnValue_t PlocMpsocSpecialComHelper::handleAck() { ReturnValue_t result = returnvalue::OK; result = handleTmReception(mpsoc::SIZE_ACK_REPORT); if (result != returnvalue::OK) { @@ -309,17 +310,18 @@ ReturnValue_t PlocMPSoCHelper::handleAck() { } uint16_t apid = tmPacket.getApid(); if (apid != mpsoc::apid::ACK_SUCCESS) { - handleAckApidFailure(apid); + handleAckApidFailure(tmPacket); return returnvalue::FAILED; } return returnvalue::OK; } -void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) { +void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& reader) { + uint16_t apid = reader.getApid(); if (apid == mpsoc::apid::ACK_FAILURE) { - triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast(internalState)); - sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Received acknowledgement failure " - << "report" << std::endl; + uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); + sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; + triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast(internalState), status); } else { triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast(internalState)); sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report " @@ -327,7 +329,7 @@ void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) { } } -ReturnValue_t PlocMPSoCHelper::handleExe() { +ReturnValue_t PlocMpsocSpecialComHelper::handleExe() { ReturnValue_t result = returnvalue::OK; result = handleTmReception(mpsoc::SIZE_EXE_REPORT); @@ -341,17 +343,18 @@ ReturnValue_t PlocMPSoCHelper::handleExe() { } uint16_t apid = tmPacket.getApid(); if (apid != mpsoc::apid::EXE_SUCCESS) { - handleExeApidFailure(apid); + handleExeApidFailure(tmPacket); return returnvalue::FAILED; } return returnvalue::OK; } -void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) { +void PlocMpsocSpecialComHelper::handleExeApidFailure(const ploc::SpTmReader& reader) { + uint16_t apid = reader.getApid(); if (apid == mpsoc::apid::EXE_FAILURE) { + uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); + sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast(internalState)); - sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Received execution failure " - << "report" << std::endl; } else { triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast(internalState)); sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report " @@ -359,7 +362,7 @@ void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) { } } -ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) { +ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception(size_t remainingBytes) { ReturnValue_t result = returnvalue::OK; size_t readBytes = 0; size_t currentBytes = 0; @@ -382,7 +385,8 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) { return result; } -ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen) { +ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofile, + size_t expectedReadLen) { SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); ReturnValue_t result = checkReceivedTm(tmPacket); if (result != returnvalue::OK) { @@ -422,7 +426,7 @@ ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { +ReturnValue_t PlocMpsocSpecialComHelper::fileCheck(std::string obcFile) { #ifdef XIPHOS_Q7S ReturnValue_t result = FilesystemHelper::checkPath(obcFile); if (result != returnvalue::OK) { @@ -438,8 +442,8 @@ ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, - std::string mpsocFile) { +ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string obcFile, + std::string mpsocFile) { ReturnValue_t result = fileCheck(obcFile); if (result != returnvalue::OK) { return result; @@ -451,7 +455,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { +ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t result = reader.checkSize(); if (result != returnvalue::OK) { sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed" @@ -475,7 +479,8 @@ ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { return returnvalue::OK; } -ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) { +ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t* readBytes, + size_t requestBytes) { ReturnValue_t result = returnvalue::OK; uint8_t* buffer = nullptr; result = uartComIF->requestReceiveMessage(comCookie, requestBytes); diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocSpecialComHelper.h similarity index 95% rename from linux/payload/PlocMpsocHelper.h rename to linux/payload/PlocMpsocSpecialComHelper.h index 2595c811..2a8e03dc 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocSpecialComHelper.h @@ -1,7 +1,7 @@ #ifndef BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ #define BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ -#include +#include #include #include @@ -23,7 +23,7 @@ * MPSoC and OBC. * @author J. Meier */ -class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { +class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF { public: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HELPER; @@ -82,8 +82,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { FLASH_READ_READLEN_ERROR = 2 }; - PlocMPSoCHelper(object_id_t objectId); - virtual ~PlocMPSoCHelper(); + PlocMpsocSpecialComHelper(object_id_t objectId); + virtual ~PlocMpsocSpecialComHelper(); ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t operationCode = 0) override; @@ -175,7 +175,7 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { void resetHelper(); ReturnValue_t performFlashWrite(); ReturnValue_t performFlashRead(); - ReturnValue_t flashfopen(); + ReturnValue_t flashfopen(mpsoc::FileAccessMode mode); ReturnValue_t flashfclose(); ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc); ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc); @@ -186,8 +186,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { ReturnValue_t handleExe(); ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); ReturnValue_t fileCheck(std::string obcFile); - void handleAckApidFailure(uint16_t apid); - void handleExeApidFailure(uint16_t apid); + void handleAckApidFailure(const ploc::SpTmReader& reader); + void handleExeApidFailure(const ploc::SpTmReader& reader); ReturnValue_t handleTmReception(size_t remainingBytes); ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader); }; diff --git a/linux/payload/plocMpsocHelpers.cpp b/linux/payload/plocMpsocHelpers.cpp new file mode 100644 index 00000000..ab6f0907 --- /dev/null +++ b/linux/payload/plocMpsocHelpers.cpp @@ -0,0 +1,91 @@ +#include "plocMpsocHelpers.h" + +uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) { + return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); +} +std::string mpsoc::getStatusString(uint16_t status) { + switch (status) { + case (mpsoc::status_code::UNKNOWN_APID): { + return "Unknown APID"; + break; + } + case (mpsoc::status_code::INCORRECT_LENGTH): { + return "Incorrect length"; + break; + } + case (mpsoc::status_code::INCORRECT_CRC): { + return "Incorrect crc"; + break; + } + case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): { + return "Incorrect packet sequence count"; + break; + } + case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): { + return "TC not allowed in this mode"; + break; + } + case (mpsoc::status_code::TC_EXEUTION_DISABLED): { + return "TC execution disabled"; + break; + } + case (mpsoc::status_code::FLASH_MOUNT_FAILED): { + return "Flash mount failed"; + break; + } + case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): { + return "Flash file already closed"; + break; + } + case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): { + return "Flash file open failed"; + break; + } + case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): { + return "Flash file not open"; + break; + } + case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): { + return "Flash unmount failed"; + break; + } + case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): { + return "Heap allocation failed"; + break; + } + case (mpsoc::status_code::INVALID_PARAMETER): { + return "Invalid parameter"; + break; + } + case (mpsoc::status_code::NOT_INITIALIZED): { + return "Not initialized"; + break; + } + case (mpsoc::status_code::REBOOT_IMMINENT): { + return "Reboot imminent"; + break; + } + case (mpsoc::status_code::CORRUPT_DATA): { + return "Corrupt data"; + break; + } + case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): { + return "Flash correctable mismatch"; + break; + } + case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): { + return "Flash uncorrectable mismatch"; + break; + } + case (mpsoc::status_code::DEFAULT_ERROR_CODE): { + return "Default error code"; + break; + } + default: + std::stringstream ss; + ss << "0x" << std::hex << status; + return ss.str().c_str(); + break; + } + return ""; +} diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpsocHelpers.h similarity index 92% rename from linux/payload/plocMpscoDefs.h rename to linux/payload/plocMpsocHelpers.h index 4bb19e4d..a7173d65 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpsocHelpers.h @@ -13,6 +13,16 @@ namespace mpsoc { +enum FileAccessMode : uint8_t { + OPEN_EXISTING = 0x00, + READ = 0x01, + WRITE = 0x02, + CREATE_NEW = 0x04, + CREATE_ALWAYS = 0x08, + OPEN_ALWAYS = 0x10, + OPEN_APPEND = 0x30 +}; + static constexpr uint32_t HK_SET_ID = 0; namespace poolid { @@ -140,6 +150,8 @@ static const char NULL_TERMINATOR = '\0'; static const uint8_t MIN_SPACE_PACKET_LENGTH = 7; static const uint8_t SPACE_PACKET_HEADER_SIZE = 6; +static const uint8_t STATUS_OFFSET = 10; + static constexpr size_t CRC_SIZE = 2; /** @@ -380,27 +392,24 @@ class FlashFopen : public ploc::SpTcBase { FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) : ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} - static const char APPEND = 'a'; - static const char WRITE = 'w'; - static const char READ = 'r'; - - ReturnValue_t createPacket(std::string filename, char accessMode_) { - accessMode = accessMode_; + ReturnValue_t createPacket(std::string filename, FileAccessMode mode) { + accessMode = mode; size_t nameSize = filename.size(); - spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE); + spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE); ReturnValue_t result = checkPayloadLen(); if (result != returnvalue::OK) { return result; } std::memcpy(payloadStart, filename.c_str(), nameSize); - *(spParams.buf + nameSize) = NULL_TERMINATOR; - std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode)); + payloadStart[nameSize] = NULL_TERMINATOR; + payloadStart[255] = NULL_TERMINATOR; + payloadStart[256] = static_cast(accessMode); updateSpFields(); return calcAndSetCrc(); } private: - char accessMode = APPEND; + FileAccessMode accessMode = FileAccessMode::OPEN_EXISTING; }; /** @@ -989,92 +998,8 @@ class HkReport : public StaticLocalDataSet<36> { lp_var_t(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this); }; -const char* getStatusString(uint16_t status) { - switch (status) { - case (mpsoc::status_code::UNKNOWN_APID): { - return "Unknown APID"; - break; - } - case (mpsoc::status_code::INCORRECT_LENGTH): { - return "Incorrect length"; - break; - } - case (mpsoc::status_code::INCORRECT_CRC): { - return "Incorrect crc"; - break; - } - case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): { - return "Incorrect packet sequence count"; - break; - } - case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): { - return "TC not allowed in this mode"; - break; - } - case (mpsoc::status_code::TC_EXEUTION_DISABLED): { - return "TC execution disabled"; - break; - } - case (mpsoc::status_code::FLASH_MOUNT_FAILED): { - return "Flash mount failed"; - break; - } - case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): { - return "Flash file already closed"; - break; - } - case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): { - return "Flash file open failed"; - break; - } - case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): { - return "Flash file not open"; - break; - } - case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): { - return "Flash unmount failed"; - break; - } - case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): { - return "Heap allocation failed"; - break; - } - case (mpsoc::status_code::INVALID_PARAMETER): { - return "Invalid parameter"; - break; - } - case (mpsoc::status_code::NOT_INITIALIZED): { - return "Not initialized"; - break; - } - case (mpsoc::status_code::REBOOT_IMMINENT): { - return "Reboot imminent"; - break; - } - case (mpsoc::status_code::CORRUPT_DATA): { - return "Corrupt data"; - break; - } - case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): { - return "Flash correctable mismatch"; - break; - } - case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): { - return "Flash uncorrectable mismatch"; - break; - } - case (mpsoc::status_code::DEFAULT_ERROR_CODE): { - return "Default error code"; - break; - } - default: - std::stringstream ss; - ss << "0x" << std::hex << status; - return ss.str(); - break; - } - return ""; -} +uint16_t getStatusFromRawData(const uint8_t* data); +std::string getStatusString(uint16_t status); } // namespace mpsoc From fabc6da562a523e9af978220095e743b33b34c7b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 15:16:44 +0200 Subject: [PATCH 043/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c151397..7c3924f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,8 @@ will consitute of a breaking change warranting a new major release: - The PLOC MPSoC now waits 10 cycles before going to on. These wait cycles are necessary because the MPSoC is not ready to process commands without this additional boot time. - Fixed correction for `GPS Altitude` in case the sensor data is out of the expected bonds. +- PLOC MPSoC special communication is now scheduled, which allows flash read and flash write + commands to work. # [v2.0.5] 2023-05-11 From 5ce0a60184d42420f8200abd3d0a5908d86910e8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 15:19:12 +0200 Subject: [PATCH 044/172] some more cleaning and refacoring --- linux/payload/PlocMpsocHandler.cpp | 32 ++++++++++++------------------ linux/payload/PlocMpsocHandler.h | 2 +- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index a07c7871..89e9a248 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -13,7 +13,7 @@ PlocMpsocHandler::PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid Gpio uartIsolatorSwitch, object_id_t supervisorHandler) : DeviceHandlerBase(objectId, uartComIFid, comCookie), hkReport(this), - plocMPSoCHelper(plocMPSoCHelper), + specialComHelper(plocMPSoCHelper), uartIsolatorSwitch(uartIsolatorSwitch), supervisorHandler(supervisorHandler), commandActionHelper(this) { @@ -65,12 +65,12 @@ ReturnValue_t PlocMpsocHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } - result = plocMPSoCHelper->setComIF(communicationInterface); + result = specialComHelper->setComIF(communicationInterface); if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - plocMPSoCHelper->setComCookie(comCookie); - plocMPSoCHelper->setSequenceCount(&sequenceCount); + specialComHelper->setComCookie(comCookie); + specialComHelper->setSequenceCount(&sequenceCount); result = commandActionHelper.initialize(); if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; @@ -136,9 +136,9 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } - plocMPSoCHelper->setSequenceCount(&sequenceCount); - result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(), - flashWritePusCmd.getMPSoCFile()); + specialComHelper->setSequenceCount(&sequenceCount); + result = specialComHelper->startFlashWrite(flashWritePusCmd.getObcFile(), + flashWritePusCmd.getMPSoCFile()); if (result != returnvalue::OK) { return result; } @@ -151,12 +151,10 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } - sif::debug << "starting flash read" << std::endl; - sif::debug << "sequence count: " << sequenceCount.get() << std::endl; - plocMPSoCHelper->setSequenceCount(&sequenceCount); - result = plocMPSoCHelper->startFlashRead(flashReadPusCmd.getObcFile(), - flashReadPusCmd.getMPSoCFile(), - flashReadPusCmd.getReadSize()); + specialComHelper->setSequenceCount(&sequenceCount); + result = specialComHelper->startFlashRead(flashReadPusCmd.getObcFile(), + flashReadPusCmd.getMPSoCFile(), + flashReadPusCmd.getReadSize()); if (result != returnvalue::OK) { return result; } @@ -790,10 +788,9 @@ ReturnValue_t PlocMpsocHandler::handleAckReport(const uint8_t* data) { switch (apid) { case mpsoc::apid::ACK_FAILURE: { - sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; DeviceCommandId_t commandId = getPendingCommand(); uint16_t status = mpsoc::getStatusFromRawData(data); - sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; + sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(ACK_FAILURE, commandId, status); } @@ -835,15 +832,12 @@ ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) { break; } case (mpsoc::apid::EXE_FAILURE): { - // TODO: Interpretation of status field in execution report - sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" - << std::endl; DeviceCommandId_t commandId = getPendingCommand(); if (commandId == DeviceHandlerIF::NO_COMMAND_ID) { sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; } uint16_t status = mpsoc::getStatusFromRawData(data); - sif::warning << "Verification report status: " << mpsoc::getStatusString(status) << std::endl; + sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; triggerEvent(EXE_FAILURE, commandId, status); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); result = IGNORE_REPLY_DATA; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index a42075d8..ea62e484 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -162,7 +162,7 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { SerialComIF* uartComIf = nullptr; - PlocMpsocSpecialComHelper* plocMPSoCHelper = nullptr; + PlocMpsocSpecialComHelper* specialComHelper = nullptr; Gpio uartIsolatorSwitch; object_id_t supervisorHandler = 0; CommandActionHelper commandActionHelper; From c8ed7fe20e53a134290dbebc292e48ef8135bf5e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 15:21:22 +0200 Subject: [PATCH 045/172] new events and retvals --- .../fsfwconfig/events/translateEvents.cpp | 13 ++++++-- .../fsfwconfig/objects/translateObjects.cpp | 2 +- generators/bsp_hosted_events.csv | 33 ++++++++++--------- generators/bsp_q7s_events.csv | 33 ++++++++++--------- generators/bsp_q7s_returnvalues.csv | 7 ++-- generators/events/translateEvents.cpp | 13 ++++++-- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 13 ++++++-- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- tmtc | 2 +- 10 files changed, 77 insertions(+), 43 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index f7850a99..63fee50d 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 291 translations. + * @brief Auto-generated event translation file. Contains 294 translations. * @details - * Generated on: 2023-04-17 11:34:19 + * Generated on: 2023-05-15 15:20:19 */ #include "translateEvents.h" @@ -197,6 +197,9 @@ const char *MPSOC_EXE_INVALID_APID_STRING = "MPSOC_EXE_INVALID_APID"; const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH"; const char *MPSOC_TM_SIZE_ERROR_STRING = "MPSOC_TM_SIZE_ERROR"; const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH"; +const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR"; +const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED"; +const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL"; const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF"; const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS"; const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS"; @@ -683,6 +686,12 @@ const char *translateEvents(Event event) { return MPSOC_TM_SIZE_ERROR_STRING; case (12613): return MPSOC_TM_CRC_MISSMATCH_STRING; + case (12614): + return MPSOC_FLASH_READ_PACKET_ERROR_STRING; + case (12615): + return MPSOC_FLASH_READ_FAILED_STRING; + case (12616): + return MPSOC_FLASH_READ_SUCCESSFUL_STRING; case (12700): return TRANSITION_BACK_TO_OFF_STRING; case (12701): diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 16235835..6ab96892 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 171 translations. - * Generated on: 2023-04-17 11:34:19 + * Generated on: 2023-05-15 15:20:19 */ #include "translateObjects.h" diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index 2d5f5693..2df4aa32 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -177,20 +177,23 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12515;0x30e3;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not exist P1: Internal state of str helper;linux/acs/StrComHandler.h 12516;0x30e4;STR_HELPER_SENDING_PACKET_FAILED;LOW;No description;linux/acs/StrComHandler.h 12517;0x30e5;STR_HELPER_REQUESTING_MSG_FAILED;LOW;No description;linux/acs/StrComHandler.h -12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocHelper.h -12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;LOW;Flash write successful;linux/payload/PlocMpsocHelper.h -12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocHelper.h -12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHelper.h -12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocHelper.h -12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocHelper.h +12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocSpecialComHelper.h +12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;INFO;Flash write successful;linux/payload/PlocMpsocSpecialComHelper.h +12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocSpecialComHelper.h +12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h 12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h 12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h 12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h @@ -274,7 +277,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 14105;0x3719;CAMERA_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14106;0x371a;PCDU_SYSTEM_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14107;0x371b;HEATER_NOT_OFF_FOR_OFF_MODE;MEDIUM;No description;mission/controller/tcsDefs.h -14108;0x371c;MGT_OVERHEATING;MEDIUM;No description;mission/controller/tcsDefs.h +14108;0x371c;MGT_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14201;0x3779;TX_TIMER_EXPIRED;INFO;The transmit timer to protect the Syrlinks expired P1: The current timer value;mission/system/com/ComSubsystem.h 14202;0x377a;BIT_LOCK_TX_ON;INFO;Transmitter will be turned on due to detection of bitlock;mission/system/com/ComSubsystem.h 14300;0x37dc;POSSIBLE_FILE_CORRUPTION;LOW;P1: Result code of TM packet parser. P2: Timestamp of possibly corrupt file as a unix timestamp.;mission/persistentTmStoreDefs.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 2d5f5693..2df4aa32 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -177,20 +177,23 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12515;0x30e3;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not exist P1: Internal state of str helper;linux/acs/StrComHandler.h 12516;0x30e4;STR_HELPER_SENDING_PACKET_FAILED;LOW;No description;linux/acs/StrComHandler.h 12517;0x30e5;STR_HELPER_REQUESTING_MSG_FAILED;LOW;No description;linux/acs/StrComHandler.h -12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocHelper.h -12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;LOW;Flash write successful;linux/payload/PlocMpsocHelper.h -12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocHelper.h -12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h -12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h -12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHelper.h -12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocHelper.h -12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocHelper.h +12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocSpecialComHelper.h +12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;INFO;Flash write successful;linux/payload/PlocMpsocSpecialComHelper.h +12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h +12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h +12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocSpecialComHelper.h +12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h +12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h 12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h 12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h 12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h @@ -274,7 +277,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 14105;0x3719;CAMERA_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14106;0x371a;PCDU_SYSTEM_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14107;0x371b;HEATER_NOT_OFF_FOR_OFF_MODE;MEDIUM;No description;mission/controller/tcsDefs.h -14108;0x371c;MGT_OVERHEATING;MEDIUM;No description;mission/controller/tcsDefs.h +14108;0x371c;MGT_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h 14201;0x3779;TX_TIMER_EXPIRED;INFO;The transmit timer to protect the Syrlinks expired P1: The current timer value;mission/system/com/ComSubsystem.h 14202;0x377a;BIT_LOCK_TX_ON;INFO;Transmitter will be turned on due to detection of bitlock;mission/system/com/ComSubsystem.h 14300;0x37dc;POSSIBLE_FILE_CORRUPTION;LOW;P1: Result code of TM packet parser. P2: Timestamp of possibly corrupt file as a unix timestamp.;mission/persistentTmStoreDefs.h diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index 20b76df6..1bc91860 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -478,8 +478,8 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x53b6;STRH_StartrackerAlreadyBooted;Star tracker is already in firmware mode;182;STR_HANDLER;mission/acs/str/StarTrackerHandler.h 0x53b7;STRH_StartrackerNotRunningFirmware;Star tracker must be in firmware mode to run this command;183;STR_HANDLER;mission/acs/str/StarTrackerHandler.h 0x53b8;STRH_StartrackerNotRunningBootloader;Star tracker must be in bootloader mode to run this command;184;STR_HANDLER;mission/acs/str/StarTrackerHandler.h -0x54e0;DWLPWRON_InvalidMode;Received command has invalid JESD mode (valid modes are 0 - 5);224;DWLPWRON_CMD;linux/payload/plocMpscoDefs.h -0x54e1;DWLPWRON_InvalidLaneRate;Received command has invalid lane rate (valid lane rate are 0 - 9);225;DWLPWRON_CMD;linux/payload/plocMpscoDefs.h +0x54e0;DWLPWRON_InvalidMode;Received command has invalid JESD mode (valid modes are 0 - 5);224;DWLPWRON_CMD;linux/payload/plocMpsocHelpers.h +0x54e1;DWLPWRON_InvalidLaneRate;Received command has invalid lane rate (valid lane rate are 0 - 9);225;DWLPWRON_CMD;linux/payload/plocMpsocHelpers.h 0x5700;PLSPVhLP_RequestDone;No description;0;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h 0x5701;PLSPVhLP_NoPacketFound;No description;1;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h 0x5702;PLSPVhLP_DecodeBufTooSmall;No description;2;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h @@ -543,7 +543,8 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NvmParameterBase.h 0x64a0;FSHLP_SdNotMounted;SD card specified with path string not mounted;160;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h 0x64a1;FSHLP_FileNotExists;Specified file does not exist on filesystem;161;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h -0x65a0;PLMPHLP_FileClosedAccidentally;File accidentally close;160;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocHelper.h +0x65a0;PLMPHLP_FileWriteError;File error occured for file transfers from OBC to the MPSoC.;160;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocSpecialComHelper.h +0x65a1;PLMPHLP_FileReadError;File error occured for file transfers from MPSoC to OBC.;161;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocSpecialComHelper.h 0x66a0;SADPL_CommandNotSupported;No description;160;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h 0x66a1;SADPL_DeploymentAlreadyExecuting;No description;161;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h 0x66a2;SADPL_MainSwitchTimeoutFailure;No description;162;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index f7850a99..63fee50d 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 291 translations. + * @brief Auto-generated event translation file. Contains 294 translations. * @details - * Generated on: 2023-04-17 11:34:19 + * Generated on: 2023-05-15 15:20:19 */ #include "translateEvents.h" @@ -197,6 +197,9 @@ const char *MPSOC_EXE_INVALID_APID_STRING = "MPSOC_EXE_INVALID_APID"; const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH"; const char *MPSOC_TM_SIZE_ERROR_STRING = "MPSOC_TM_SIZE_ERROR"; const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH"; +const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR"; +const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED"; +const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL"; const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF"; const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS"; const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS"; @@ -683,6 +686,12 @@ const char *translateEvents(Event event) { return MPSOC_TM_SIZE_ERROR_STRING; case (12613): return MPSOC_TM_CRC_MISSMATCH_STRING; + case (12614): + return MPSOC_FLASH_READ_PACKET_ERROR_STRING; + case (12615): + return MPSOC_FLASH_READ_FAILED_STRING; + case (12616): + return MPSOC_FLASH_READ_SUCCESSFUL_STRING; case (12700): return TRANSITION_BACK_TO_OFF_STRING; case (12701): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 1c252ec5..458e8d67 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 175 translations. - * Generated on: 2023-04-17 11:34:19 + * Generated on: 2023-05-15 15:20:19 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index f7850a99..63fee50d 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 291 translations. + * @brief Auto-generated event translation file. Contains 294 translations. * @details - * Generated on: 2023-04-17 11:34:19 + * Generated on: 2023-05-15 15:20:19 */ #include "translateEvents.h" @@ -197,6 +197,9 @@ const char *MPSOC_EXE_INVALID_APID_STRING = "MPSOC_EXE_INVALID_APID"; const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH"; const char *MPSOC_TM_SIZE_ERROR_STRING = "MPSOC_TM_SIZE_ERROR"; const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH"; +const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR"; +const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED"; +const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL"; const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF"; const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS"; const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS"; @@ -683,6 +686,12 @@ const char *translateEvents(Event event) { return MPSOC_TM_SIZE_ERROR_STRING; case (12613): return MPSOC_TM_CRC_MISSMATCH_STRING; + case (12614): + return MPSOC_FLASH_READ_PACKET_ERROR_STRING; + case (12615): + return MPSOC_FLASH_READ_FAILED_STRING; + case (12616): + return MPSOC_FLASH_READ_SUCCESSFUL_STRING; case (12700): return TRANSITION_BACK_TO_OFF_STRING; case (12701): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 1c252ec5..458e8d67 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 175 translations. - * Generated on: 2023-04-17 11:34:19 + * Generated on: 2023-05-15 15:20:19 */ #include "translateObjects.h" diff --git a/tmtc b/tmtc index 280c7243..b8e1c7af 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 280c72439effa1b4290dc500dade2c62a9d6e3f7 +Subproject commit b8e1c7afe91bddfea2b139217320033f3a3b0efb From 78972cd173194b9a05151ea571f24f1448eb9631 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 16:16:17 +0200 Subject: [PATCH 046/172] remove some more printouts --- linux/payload/PlocMpsocSpecialComHelper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 6bc338c6..d54090a4 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -181,7 +181,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (ofile.bad()) { return returnvalue::FAILED; } - sif::debug << "Sequence count: " << sequenceCount->get() << std::endl; ReturnValue_t result = flashfopen(mpsoc::FileAccessMode::READ); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); From 3d7d01d6abc3cce17c9cee2280209aa94fb81d87 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 16:17:08 +0200 Subject: [PATCH 047/172] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 0c1bfc6f..280c7243 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 0c1bfc6fd32e66fe0da13bebc4eeb3030ead13a9 +Subproject commit 280c72439effa1b4290dc500dade2c62a9d6e3f7 From a615ed2d21cb7543249ecae2ecb3f7fb84dfd138 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 16:18:44 +0200 Subject: [PATCH 048/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 5eb9ee8b..4391823f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5eb9ee8bc1e6f8640cbea46febd11e4b92241881 +Subproject commit 4391823f01d792bcc078d47b60f7df7624f8cbe4 From 97a7087827e0430085fd5ff398a86a31c6c8dc34 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 16:45:14 +0200 Subject: [PATCH 049/172] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 280c7243..5f379bf2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 280c72439effa1b4290dc500dade2c62a9d6e3f7 +Subproject commit 5f379bf2bb76f5cc65e9ca58036a4b239d8638b8 From ab6a0c3e4d4b52dc7e8d0c95d80747630fc41664 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 15 May 2023 16:49:16 +0200 Subject: [PATCH 050/172] fix host build --- bsp_hosted/ObjectFactory.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index d792b57b..018d0e56 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -39,7 +39,7 @@ #include "devices/gpioIds.h" #include "fsfw_hal/linux/gpio/Gpio.h" #include "linux/payload/PlocMpsocHandler.h" -#include "linux/payload/PlocMpsocHelper.h" +#include "linux/payload/PlocMpsocSpecialComHelper.h" #include "linux/payload/PlocSupervisorHandler.h" #include "linux/payload/PlocSupvUartMan.h" #include "test/gpio/DummyGpioIF.h" @@ -82,8 +82,8 @@ void ObjectFactory::produce(void* args) { auto mpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, mpscoDev, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); mpsocCookie->setNoFixedSizeReply(); - auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); - new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, + auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER); + new PlocMpsocHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, dummyGpioIF), objects::PLOC_SUPERVISOR_HANDLER); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ From b39e448ab555f65d8cf2d70c82c6d30455cfc896 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 May 2023 08:19:30 +0200 Subject: [PATCH 051/172] correction for flashfclose cmd --- linux/payload/plocMpsocHelpers.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index a7173d65..702df949 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -419,18 +419,6 @@ class FlashFclose : public ploc::SpTcBase { public: FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount) : ploc::SpTcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {} - - ReturnValue_t createPacket(std::string filename) { - size_t nameSize = filename.size(); - spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE); - ReturnValue_t result = checkPayloadLen(); - if (result != returnvalue::OK) { - return result; - } - std::memcpy(payloadStart, filename.c_str(), nameSize); - *(payloadStart + nameSize) = NULL_TERMINATOR; - return calcAndSetCrc(); - } }; /** From 468fa016504496c1adbe5df01ca614cd961d5517 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 May 2023 11:08:33 +0200 Subject: [PATCH 052/172] bugfix --- linux/payload/PlocMpsocSpecialComHelper.cpp | 6 ++---- linux/payload/plocMpsocHelpers.h | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index d54090a4..f8b81603 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -249,10 +250,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() { spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); - ReturnValue_t result = flashFclose.createPacket(flashReadAndWrite.mpsocFile); - if (result != returnvalue::OK) { - return result; - } return handlePacketTransmissionNoReply(flashFclose); } @@ -287,6 +284,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; + arrayprinter::print(tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 702df949..c65d20e0 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -387,10 +387,10 @@ class TcMemWrite : public TcBase { /** * @brief Class to help creation of flash fopen command. */ -class FlashFopen : public ploc::SpTcBase { +class FlashFopen : public TcBase { public: FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) - : ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} + : TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} ReturnValue_t createPacket(std::string filename, FileAccessMode mode) { accessMode = mode; @@ -415,19 +415,19 @@ class FlashFopen : public ploc::SpTcBase { /** * @brief Class to help creation of flash fclose command. */ -class FlashFclose : public ploc::SpTcBase { +class FlashFclose : public TcBase { public: FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount) - : ploc::SpTcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {} + : TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {} }; /** * @brief Class to build flash write space packet. */ -class TcFlashWrite : public ploc::SpTcBase { +class TcFlashWrite : public TcBase { public: TcFlashWrite(ploc::SpTcParams params, uint16_t sequenceCount) - : ploc::SpTcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} + : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} ReturnValue_t buildPacket(const uint8_t* writeData, uint32_t writeLen_) { ReturnValue_t result = returnvalue::OK; @@ -460,10 +460,10 @@ class TcFlashWrite : public ploc::SpTcBase { uint32_t writeLen = 0; }; -class TcFlashRead : public ploc::SpTcBase { +class TcFlashRead : public TcBase { public: TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount) - : ploc::SpTcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} + : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} ReturnValue_t buildPacket(uint32_t readLen) { if (readLen > MAX_FLASH_READ_DATA_SIZE) { @@ -500,10 +500,10 @@ class TcFlashRead : public ploc::SpTcBase { /** * @brief Class to help creation of flash delete command. */ -class TcFlashDelete : public ploc::SpTcBase { +class TcFlashDelete : public TcBase { public: TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount) - : ploc::SpTcBase(params, apid::TC_FLASHDELETE, sequenceCount) {} + : TcBase(params, apid::TC_FLASHDELETE, sequenceCount) {} ReturnValue_t buildPacket(std::string filename) { size_t nameSize = filename.size(); From 4ba9ebf58f15f1c4db5b87c4c5a08ad3f65b8b7a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 May 2023 13:34:06 +0200 Subject: [PATCH 053/172] kenning west alder --- linux/payload/PlocMpsocHandler.cpp | 103 +++++++------------- linux/payload/PlocMpsocHandler.h | 2 +- linux/payload/PlocMpsocSpecialComHelper.cpp | 14 ++- linux/payload/plocMpsocHelpers.h | 68 ++++--------- 4 files changed, 65 insertions(+), 122 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 89e9a248..856f888d 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -562,11 +562,11 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemWrite(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount); - result = tcMemWrite.buildPacket(commandData, commandDataLen); + result = tcMemWrite.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcMemWrite.getFullPacketLen()); + finishTcPrep(tcMemWrite); return returnvalue::OK; } @@ -574,11 +574,11 @@ ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcMemRead tcMemRead(spParams, sequenceCount); - result = tcMemRead.buildPacket(commandData, commandDataLen); + result = tcMemRead.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcMemRead.getFullPacketLen()); + finishTcPrep(tcMemRead); tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE; return returnvalue::OK; } @@ -590,12 +590,12 @@ ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData, } ReturnValue_t result = returnvalue::OK; mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount); - result = tcFlashDelete.buildPacket( - std::string(reinterpret_cast(commandData), commandDataLen)); + std::string filename = std::string(reinterpret_cast(commandData), commandDataLen); + result = tcFlashDelete.setPayload(filename); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcFlashDelete.getFullPacketLen()); + finishTcPrep(tcFlashDelete); return returnvalue::OK; } @@ -603,22 +603,17 @@ ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount); - result = tcReplayStart.buildPacket(commandData, commandDataLen); + result = tcReplayStart.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcReplayStart.getFullPacketLen()); + finishTcPrep(tcReplayStart); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount); - result = tcReplayStop.buildPacket(); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcReplayStop.getFullPacketLen()); + finishTcPrep(tcReplayStop); return returnvalue::OK; } @@ -626,78 +621,49 @@ ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount); - result = tcDownlinkPwrOn.buildPacket(commandData, commandDataLen); + result = tcDownlinkPwrOn.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcDownlinkPwrOn.getFullPacketLen()); + finishTcPrep(tcDownlinkPwrOn); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount); - result = tcDownlinkPwrOff.buildPacket(); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcDownlinkPwrOff.getFullPacketLen()); + finishTcPrep(tcDownlinkPwrOff); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() { mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount); - ReturnValue_t result = tcGetHkReport.buildPacket(); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcGetHkReport.getFullPacketLen()); + finishTcPrep(tcGetHkReport); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount); - result = tcReplayWriteSeq.buildPacket(commandData, commandDataLen); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcReplayWriteSeq.getFullPacketLen()); + finishTcPrep(tcReplayWriteSeq); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount); - result = tcModeReplay.buildPacket(); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcModeReplay.getFullPacketLen()); + finishTcPrep(tcModeReplay); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount); - result = tcModeIdle.buildPacket(); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcModeIdle.getFullPacketLen()); + finishTcPrep(tcModeIdle); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount); - result = tcCamCmdSend.buildPacket(commandData, commandDataLen); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcCamCmdSend.getFullPacketLen()); + finishTcPrep(tcCamCmdSend); nextReplyId = mpsoc::TM_CAM_CMD_RPT; return returnvalue::OK; } @@ -705,62 +671,59 @@ ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); - ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcCamTakePic.getFullPacketLen()); + finishTcPrep(tcCamTakePic); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); - ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcSimplexSendFile.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcSimplexSendFile.getFullPacketLen()); + finishTcPrep(tcSimplexSendFile); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount); - ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcGetDirContent.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcGetDirContent.getFullPacketLen()); + finishTcPrep(tcGetDirContent); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); - ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcDownlinkDataModulate.setPayload(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcDownlinkDataModulate.getFullPacketLen()); + finishTcPrep(tcDownlinkDataModulate); return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() { mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); - ReturnValue_t result = tcModeSnapshot.buildPacket(); - if (result != returnvalue::OK) { - return result; - } - finishTcPrep(tcModeSnapshot.getFullPacketLen()); + finishTcPrep(tcModeSnapshot); return returnvalue::OK; } -void PlocMpsocHandler::finishTcPrep(size_t packetLen) { +ReturnValue_t PlocMpsocHandler::finishTcPrep(mpsoc::TcBase& tcBase) { nextReplyId = mpsoc::ACK_REPORT; + ReturnValue_t result = tcBase.finishPacket(); + if (result != returnvalue::OK) { + return result; + } rawPacket = commandBuffer; - rawPacketLen = packetLen; + rawPacketLen = tcBase.getFullPacketLen(); sequenceCount++; + return returnvalue::OK; } ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) { diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index ea62e484..e0474a33 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -214,7 +214,7 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcModeSnapshot(); - void finishTcPrep(size_t packetLen); + ReturnValue_t finishTcPrep(mpsoc::TcBase& tcBase); /** * @brief This function checks the crc of the received PLOC reply. diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index f8b81603..78fa430f 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -207,7 +207,13 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { } (*sequenceCount)++; mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); - result = flashReadRequest.buildPacket(nextReadSize); + result = flashReadRequest.setPayload(nextReadSize); + if (result != returnvalue::OK) { + std::filesystem::remove(flashReadAndWrite.obcFile, e); + flashfclose(); + return result; + } + result = flashReadRequest.finishPacket(); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); flashfclose(); @@ -235,7 +241,11 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) spParams.buf = commandBuffer; (*sequenceCount)++; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); - ReturnValue_t result = flashFopen.createPacket(flashReadAndWrite.mpsocFile, mode); + ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode); + if (result != returnvalue::OK) { + return result; + } + result = flashFopen.finishPacket(); if (result != returnvalue::OK) { return result; } diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index c65d20e0..c896be3d 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -239,47 +239,23 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF { */ TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount) : ploc::SpTcBase(params, apid, 0, sequenceCount) { + payloadStart = spParams.buf + ccsds::HEADER_LEN; spParams.setFullPayloadLen(INIT_LENGTH); } - ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); } - /** - * @brief Function to initialize the space packet - * - * @param commandData Pointer to command specific data - * @param commandDataLen Length of command data - * + * @brief Function to finsh and write the space packet. It is expected that the user has + * set the payload fields in the child class* * @return returnvalue::OK if packet creation was successful, otherwise error return value */ - ReturnValue_t buildPacket(const uint8_t* commandData, size_t commandDataLen) { - payloadStart = spParams.buf + ccsds::HEADER_LEN; - ReturnValue_t res; - if (commandData != nullptr and commandDataLen > 0) { - res = initPacket(commandData, commandDataLen); - if (res != returnvalue::OK) { - return res; - } - } - + ReturnValue_t finishPacket() { updateSpFields(); - res = checkSizeAndSerializeHeader(); + ReturnValue_t res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } return calcAndSetCrc(); } - - protected: - /** - * @brief Must be overwritten by the child class to define the command specific parameters - * - * @param commandData Pointer to received command data - * @param commandDataLen Length of received command data - */ - virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { - return returnvalue::OK; - } }; /** @@ -297,8 +273,7 @@ class TcMemRead : public TcBase { uint16_t getMemLen() const { return memLen; } - protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; result = lengthCheck(commandDataLen); if (result != returnvalue::OK) { @@ -344,8 +319,7 @@ class TcMemWrite : public TcBase { TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {} - protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; result = lengthCheck(commandDataLen); if (result != returnvalue::OK) { @@ -392,7 +366,7 @@ class FlashFopen : public TcBase { FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} - ReturnValue_t createPacket(std::string filename, FileAccessMode mode) { + ReturnValue_t setPayload(std::string filename, FileAccessMode mode) { accessMode = mode; size_t nameSize = filename.size(); spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE); @@ -404,8 +378,7 @@ class FlashFopen : public TcBase { payloadStart[nameSize] = NULL_TERMINATOR; payloadStart[255] = NULL_TERMINATOR; payloadStart[256] = static_cast(accessMode); - updateSpFields(); - return calcAndSetCrc(); + return returnvalue::OK; } private: @@ -465,7 +438,7 @@ class TcFlashRead : public TcBase { TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} - ReturnValue_t buildPacket(uint32_t readLen) { + ReturnValue_t setPayload(uint32_t readLen) { if (readLen > MAX_FLASH_READ_DATA_SIZE) { sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl; return returnvalue::FAILED; @@ -505,7 +478,7 @@ class TcFlashDelete : public TcBase { TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_FLASHDELETE, sequenceCount) {} - ReturnValue_t buildPacket(std::string filename) { + ReturnValue_t setPayload(std::string filename) { size_t nameSize = filename.size(); spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE); auto res = checkPayloadLen(); @@ -544,8 +517,7 @@ class TcReplayStart : public TcBase { TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_REPLAY_START, sequenceCount) {} - protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); result = lengthCheck(commandDataLen); @@ -593,8 +565,7 @@ class TcDownlinkPwrOn : public TcBase { TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {} - protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; result = lengthCheck(commandDataLen); if (result != returnvalue::OK) { @@ -667,7 +638,7 @@ class TcGetDirContent : public TcBase { TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {} - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; // Yeah it needs to be 256.. even if the path is shorter. spParams.setFullPayloadLen(256 + CRC_SIZE); @@ -700,8 +671,7 @@ class TcReplayWriteSeq : public TcBase { TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {} - protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE); result = lengthCheck(commandDataLen); @@ -828,7 +798,7 @@ class TcCamTakePic : public TcBase { TcCamTakePic(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {} - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > MAX_DATA_LENGTH) { return INVALID_LENGTH; } @@ -857,7 +827,7 @@ class TcSimplexSendFile : public TcBase { TcSimplexSendFile(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {} - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > MAX_DATA_LENGTH) { return INVALID_LENGTH; } @@ -882,7 +852,7 @@ class TcDownlinkDataModulate : public TcBase { TcDownlinkDataModulate(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_DOWNLINK_DATA_MODULATE, sequenceCount) {} - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > MAX_DATA_LENGTH) { return INVALID_LENGTH; } @@ -901,7 +871,7 @@ class TcCamcmdSend : public TcBase { : TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {} protected: - ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { + ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > MAX_DATA_LENGTH) { return INVALID_LENGTH; } From 90b7f069dc3824288b2352b3032216c7a71fa534 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 May 2023 18:41:04 +0200 Subject: [PATCH 054/172] it is getting annoying again --- linux/payload/PlocMpsocHandler.cpp | 17 +- linux/payload/PlocMpsocSpecialComHelper.cpp | 177 ++++++++++++-------- linux/payload/PlocMpsocSpecialComHelper.h | 15 +- linux/payload/plocMpsocHelpers.h | 8 +- 4 files changed, 136 insertions(+), 81 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 856f888d..4167b68c 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -136,7 +136,6 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } - specialComHelper->setSequenceCount(&sequenceCount); result = specialComHelper->startFlashWrite(flashWritePusCmd.getObcFile(), flashWritePusCmd.getMPSoCFile()); if (result != returnvalue::OK) { @@ -151,7 +150,6 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } - specialComHelper->setSequenceCount(&sequenceCount); result = specialComHelper->startFlashRead(flashReadPusCmd.getObcFile(), flashReadPusCmd.getMPSoCFile(), flashReadPusCmd.getReadSize()); @@ -226,9 +224,8 @@ void PlocMpsocHandler::doShutDown() { uartIsolatorSwitch.pullLow(); commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC); powerState = PowerState::SHUTDOWN; - break; + return; case PowerState::OFF: - sequenceCount = 0; hkReport.setReportingEnabled(false); setMode(_MODE_POWER_DOWN); break; @@ -236,13 +233,19 @@ void PlocMpsocHandler::doShutDown() { break; } #else - sequenceCount = 0; uartIsolatorSwitch.pullLow(); - hkReport.setReportingEnabled(false); - setMode(_MODE_POWER_DOWN); powerState = PowerState::OFF; #endif #endif + + if (specialComHelper != nullptr) { + specialComHelper->stopProcess(); + } + hkReport.setReportingEnabled(false); + setMode(_MODE_POWER_DOWN); + commandIsPending = false; + sequenceCount = 0; + plocMPSoCHelperExecuting = false; startupState = StartupState::IDLE; } diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 78fa430f..7b3cf264 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include @@ -40,16 +42,15 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode) #endif switch (internalState) { case InternalState::IDLE: { - sif::debug << "ploc mpsoc helper idle" << std::endl; semaphore.acquire(); break; } case InternalState::FLASH_WRITE: { result = performFlashWrite(); if (result == returnvalue::OK) { - triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL); + triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, sequenceCount->get()); } else { - triggerEvent(MPSOC_FLASH_WRITE_FAILED); + triggerEvent(MPSOC_FLASH_WRITE_FAILED, sequenceCount->get()); } internalState = InternalState::IDLE; break; @@ -57,9 +58,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode) case InternalState::FLASH_READ: { result = performFlashRead(); if (result == returnvalue::OK) { - triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL); + triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, sequenceCount->get()); } else { - triggerEvent(MPSOC_FLASH_READ_FAILED); + triggerEvent(MPSOC_FLASH_READ_FAILED, sequenceCount->get()); } internalState = InternalState::IDLE; break; @@ -155,13 +156,18 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { file.read(reinterpret_cast(fileBuf.data()), dataLength); bytesRead += dataLength; remainingSize -= dataLength; - (*sequenceCount)++; mpsoc::TcFlashWrite tc(spParams, *sequenceCount); - result = tc.buildPacket(fileBuf.data(), dataLength); + result = tc.setPayload(fileBuf.data(), dataLength); if (result != returnvalue::OK) { flashfclose(); return result; } + result = tc.finishPacket(); + if (result != returnvalue::OK) { + flashfclose(); + return result; + } + (*sequenceCount)++; result = handlePacketTransmissionNoReply(tc); if (result != returnvalue::OK) { flashfclose(); @@ -205,7 +211,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { flashfclose(); return FILE_READ_ERROR; } - (*sequenceCount)++; mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); result = flashReadRequest.setPayload(nextReadSize); if (result != returnvalue::OK) { @@ -219,15 +224,11 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { flashfclose(); return result; } - result = handlePacketTransmissionFlashRead(flashReadRequest); - if (result != returnvalue::OK) { - std::filesystem::remove(flashReadAndWrite.obcFile, e); - flashfclose(); - return result; - } - result = handleFlashReadReply(ofile, nextReadSize); + (*sequenceCount)++; + result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + sif::debug << "flash close" << std::endl; flashfclose(); return result; } @@ -239,7 +240,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) { spParams.buf = commandBuffer; - (*sequenceCount)++; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode); if (result != returnvalue::OK) { @@ -249,6 +249,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) if (result != returnvalue::OK) { return result; } + (*sequenceCount)++; result = handlePacketTransmissionNoReply(flashFopen); if (result != returnvalue::OK) { return result; @@ -258,12 +259,22 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() { spParams.buf = commandBuffer; - (*sequenceCount)++; mpsoc::FlashFclose flashFclose(spParams, *sequenceCount); - return handlePacketTransmissionNoReply(flashFclose); + ReturnValue_t result = flashFclose.finishPacket(); + if (result != returnvalue::OK) { + return result; + } + (*sequenceCount)++; + result = handlePacketTransmissionNoReply(flashFclose); + if (result != returnvalue::OK) { + return result; + } + return result; } -ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc) { +ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc, + std::ofstream& ofile, + size_t expectedReadLen) { ReturnValue_t result = sendCommand(tc); if (result != returnvalue::OK) { return result; @@ -272,12 +283,29 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc if (result != returnvalue::OK) { return result; } - result = handleTmReception(ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + - mpsoc::CRC_SIZE); + // ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + mpsoc::CRC_SIZE + result = handleTmReception(); if (result != returnvalue::OK) { return result; } - return handleExe(); + + // We have the nominal case where the flash read report appears first, or the case where we + // get an EXE failure immediately. + if (spReader.getApid() == mpsoc::apid::TM_FLASH_READ_REPORT) { + result = handleFlashReadReply(ofile, expectedReadLen); + if (result != returnvalue::OK) { + return result; + } + return handleExe(); + } else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) { + handleExeFailure(); + } else { + triggerEvent(MPSOC_EXE_INVALID_APID, spReader.getApid(), static_cast(internalState)); + sif::warning << "PLOC MPSoC: Expected execution report " + << "but received space packet with apid " << std::hex << spReader.getApid() + << std::endl; + } + return returnvalue::FAILED; } ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) { @@ -294,7 +322,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; - arrayprinter::print(tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; @@ -306,12 +333,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t PlocMpsocSpecialComHelper::handleAck() { ReturnValue_t result = returnvalue::OK; - result = handleTmReception(mpsoc::SIZE_ACK_REPORT); + result = handleTmReception(); if (result != returnvalue::OK) { return result; } SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); - result = checkReceivedTm(tmPacket); + result = checkReceivedTm(); if (result != returnvalue::OK) { return result; } @@ -327,7 +354,7 @@ void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& rea uint16_t apid = reader.getApid(); if (apid == mpsoc::apid::ACK_FAILURE) { uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); - sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; + sif::warning << "PLOC MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast(internalState), status); } else { triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast(internalState)); @@ -339,74 +366,93 @@ void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& rea ReturnValue_t PlocMpsocSpecialComHelper::handleExe() { ReturnValue_t result = returnvalue::OK; - result = handleTmReception(mpsoc::SIZE_EXE_REPORT); + result = handleTmReception(); if (result != returnvalue::OK) { return result; } - ploc::SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); - result = checkReceivedTm(tmPacket); + result = checkReceivedTm(); if (result != returnvalue::OK) { return result; } - uint16_t apid = tmPacket.getApid(); - if (apid != mpsoc::apid::EXE_SUCCESS) { - handleExeApidFailure(tmPacket); + uint16_t apid = spReader.getApid(); + if (apid == mpsoc::apid::EXE_FAILURE) { + handleExeFailure(); return returnvalue::FAILED; + } else if (apid != mpsoc::apid::EXE_SUCCESS) { + triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast(internalState)); + sif::warning << "PLOC MPSoC: Expected execution report " + << "but received space packet with apid " << std::hex << apid << std::endl; } return returnvalue::OK; } -void PlocMpsocSpecialComHelper::handleExeApidFailure(const ploc::SpTmReader& reader) { - uint16_t apid = reader.getApid(); - if (apid == mpsoc::apid::EXE_FAILURE) { - uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); - sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; - triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast(internalState)); - } else { - triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast(internalState)); - sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report " - << "but received space packet with apid " << std::hex << apid << std::endl; - } +void PlocMpsocSpecialComHelper::handleExeFailure() { + uint16_t status = mpsoc::getStatusFromRawData(spReader.getFullData()); + sif::warning << "PLOC MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; + triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast(internalState)); } -ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception(size_t remainingBytes) { +ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { ReturnValue_t result = returnvalue::OK; + tmCountdown.resetTimer(); size_t readBytes = 0; size_t currentBytes = 0; - for (int retries = 0; retries < RETRIES; retries++) { - result = receive(tmBuf.data() + readBytes, ¤tBytes, remainingBytes); + uint32_t usleepDelay = 5; + size_t fullPacketLen = 0; + while (true) { + if (tmCountdown.hasTimedOut()) { + triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs()); + return returnvalue::FAILED; + } + result = receive(tmBuf.data() + readBytes, 6, ¤tBytes); if (result != returnvalue::OK) { return result; } + spReader.setReadOnlyData(tmBuf.data(), tmBuf.size()); + fullPacketLen = spReader.getFullPacketLen(); readBytes += currentBytes; - remainingBytes = remainingBytes - currentBytes; - if (remainingBytes == 0) { + if (readBytes == 6) { break; } + usleep(usleepDelay); + if (usleepDelay < 200000) { + usleepDelay *= 4; + } } - if (remainingBytes != 0) { - sif::warning << "PlocMPSoCHelper::handleTmReception: Failed to receive reply" << std::endl; - triggerEvent(MPSOC_MISSING_EXE, remainingBytes, static_cast(internalState)); - return returnvalue::FAILED; + sif::debug << "recvd first 6 bytes" << std::endl; + while (true) { + if (tmCountdown.hasTimedOut()) { + triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs()); + return returnvalue::FAILED; + } + result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, ¤tBytes); + readBytes += currentBytes; + if (fullPacketLen == readBytes) { + sif::debug << "recvd full " << fullPacketLen << std::endl; + break; + } + usleep(usleepDelay); + if (usleepDelay < 200000) { + usleepDelay *= 4; + } } return result; } ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen) { - SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); - ReturnValue_t result = checkReceivedTm(tmPacket); + ReturnValue_t result = checkReceivedTm(); if (result != returnvalue::OK) { return result; } - uint16_t apid = tmPacket.getApid(); + uint16_t apid = spReader.getApid(); if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) { triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR); sif::warning << "PLOC MPSoC Flash Read: Unexpected APID" << std::endl; return result; } - const uint8_t* packetData = tmPacket.getPacketData(); - size_t deserDummy = tmPacket.getPacketDataLen() - mpsoc::CRC_SIZE; + const uint8_t* packetData = spReader.getPacketData(); + size_t deserDummy = spReader.getPacketDataLen() - mpsoc::CRC_SIZE; uint32_t receivedReadLen = 0; std::string receivedShortName = std::string(reinterpret_cast(packetData), 12); if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 12)) { @@ -462,21 +508,20 @@ ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string o return returnvalue::OK; } -ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) { - ReturnValue_t result = reader.checkSize(); +ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() { + ReturnValue_t result = spReader.checkSize(); if (result != returnvalue::OK) { - sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed" - << std::endl; + sif::error << "PLOC MPSoC: Size check on received TM failed" << std::endl; triggerEvent(MPSOC_TM_SIZE_ERROR); return result; } - reader.checkCrc(); + spReader.checkCrc(); if (result != returnvalue::OK) { - sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl; + sif::warning << "PLOC MPSoC: CRC check failed" << std::endl; triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount); return result; } - uint16_t recvSeqCnt = reader.getSequenceCount(); + uint16_t recvSeqCnt = spReader.getSequenceCount(); if (recvSeqCnt != *sequenceCount) { triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt); *sequenceCount = recvSeqCnt; @@ -486,8 +531,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm(SpTmReader& reader) { return returnvalue::OK; } -ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t* readBytes, - size_t requestBytes) { +ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t requestBytes, + size_t* readBytes) { ReturnValue_t result = returnvalue::OK; uint8_t* buffer = nullptr; result = uartComIF->requestReceiveMessage(comCookie, requestBytes); diff --git a/linux/payload/PlocMpsocSpecialComHelper.h b/linux/payload/PlocMpsocSpecialComHelper.h index 2a8e03dc..4b829c63 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.h +++ b/linux/payload/PlocMpsocSpecialComHelper.h @@ -75,6 +75,7 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF static const Event MPSOC_FLASH_READ_PACKET_ERROR = MAKE_EVENT(14, severity::LOW); static const Event MPSOC_FLASH_READ_FAILED = MAKE_EVENT(15, severity::LOW); static const Event MPSOC_FLASH_READ_SUCCESSFUL = MAKE_EVENT(16, severity::INFO); + static const Event MPSOC_READ_TIMEOUT = MAKE_EVENT(17, severity::LOW); enum FlashReadErrorType : uint32_t { FLASH_READ_APID_ERROR = 0, @@ -157,6 +158,8 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF SpacePacketCreator creator; ploc::SpTcParams spParams = ploc::SpTcParams(creator); + Countdown tmCountdown = Countdown(5000); + std::array fileBuf{}; std::array tmBuf{}; @@ -171,6 +174,7 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF CookieIF* comCookie = nullptr; // Sequence count, must be set by Ploc MPSoC Handler SourceSequenceCounter* sequenceCount = nullptr; + ploc::SpTmReader spReader; void resetHelper(); ReturnValue_t performFlashWrite(); @@ -178,18 +182,19 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF ReturnValue_t flashfopen(mpsoc::FileAccessMode mode); ReturnValue_t flashfclose(); ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc); - ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc); + ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc, std::ofstream& ofile, + size_t expectedReadLen); ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen); ReturnValue_t sendCommand(ploc::SpTcBase& tc); - ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes); + ReturnValue_t receive(uint8_t* data, size_t requestBytes, size_t* readBytes); ReturnValue_t handleAck(); ReturnValue_t handleExe(); ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); ReturnValue_t fileCheck(std::string obcFile); void handleAckApidFailure(const ploc::SpTmReader& reader); - void handleExeApidFailure(const ploc::SpTmReader& reader); - ReturnValue_t handleTmReception(size_t remainingBytes); - ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader); + void handleExeFailure(); + ReturnValue_t handleTmReception(); + ReturnValue_t checkReceivedTm(); }; #endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */ diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index c896be3d..820b479a 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -229,7 +229,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF { virtual ~TcBase() = default; // Initial length field of space packet. Will always be updated when packet is created. - static const uint16_t INIT_LENGTH = 2; + static const uint16_t INIT_LENGTH = CRC_SIZE; /** * @brief Constructor @@ -391,7 +391,9 @@ class FlashFopen : public TcBase { class FlashFclose : public TcBase { public: FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount) - : TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {} + : TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) { + spParams.setFullPayloadLen(CRC_SIZE); + } }; /** @@ -402,7 +404,7 @@ class TcFlashWrite : public TcBase { TcFlashWrite(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} - ReturnValue_t buildPacket(const uint8_t* writeData, uint32_t writeLen_) { + ReturnValue_t setPayload(const uint8_t* writeData, uint32_t writeLen_) { ReturnValue_t result = returnvalue::OK; writeLen = writeLen_; if (writeLen > SP_MAX_DATA_SIZE) { From c3b6b0a7ee4559ea3cb885c6f99560899ef55034 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 May 2023 18:46:13 +0200 Subject: [PATCH 055/172] pure chaos --- linux/payload/PlocMpsocHandler.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 4167b68c..750b64d7 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -219,18 +219,14 @@ void PlocMpsocHandler::doStartUp() { void PlocMpsocHandler::doShutDown() { #ifdef XIPHOS_Q7S #if not OBSW_MPSOC_JTAG_BOOT == 1 - switch (powerState) { - case PowerState::ON: - uartIsolatorSwitch.pullLow(); - commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC); - powerState = PowerState::SHUTDOWN; - return; - case PowerState::OFF: - hkReport.setReportingEnabled(false); - setMode(_MODE_POWER_DOWN); - break; - default: - break; + if (powerState == PowerState::ON) { + uartIsolatorSwitch.pullLow(); + commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC); + powerState = PowerState::SHUTDOWN; + return; + } else if (powerState == PowerState::SHUTDOWN) { + // Wait till power state is OFF. + return; } #else uartIsolatorSwitch.pullLow(); From 0179c04472874f1ef4aa47c7abbb60cef3d43277 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 12:59:29 +0200 Subject: [PATCH 056/172] that did not help --- linux/payload/PlocMpsocSpecialComHelper.cpp | 18 ++++++++++++++---- linux/payload/plocMpsocHelpers.h | 7 ++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 7b3cf264..20e9acca 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -198,6 +198,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { while (readSoFar < flashReadAndWrite.totalReadSize) { if (terminate) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return returnvalue::OK; } @@ -208,6 +209,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { sif::debug << "reading " << nextReadSize << " bytes from offset " << readSoFar << std::endl; if (ofile.bad() or not ofile.is_open()) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return FILE_READ_ERROR; } @@ -215,12 +217,14 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { result = flashReadRequest.setPayload(nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return result; } result = flashReadRequest.finishPacket(); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); + // TODO: Might not be needed flashfclose(); return result; } @@ -228,7 +232,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - sif::debug << "flash close" << std::endl; + // TODO: Might not be needed flashfclose(); return result; } @@ -283,7 +287,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc if (result != returnvalue::OK) { return result; } - // ccsds::HEADER_LEN + mpsoc::FLASH_READ_MIN_OVERHEAD + tc.readSize + mpsoc::CRC_SIZE result = handleTmReception(); if (result != returnvalue::OK) { return result; @@ -296,6 +299,10 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc if (result != returnvalue::OK) { return result; } + result = handleTmReception(); + if (result != returnvalue::OK) { + return result; + } return handleExe(); } else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) { handleExeFailure(); @@ -322,6 +329,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; + sif::debug << "sending TC" << std::endl; + arrayprinter::print(tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; @@ -419,7 +428,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { usleepDelay *= 4; } } - sif::debug << "recvd first 6 bytes" << std::endl; + // sif::debug << "recvd first 6 bytes" << std::endl; while (true) { if (tmCountdown.hasTimedOut()) { triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs()); @@ -428,7 +437,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, ¤tBytes); readBytes += currentBytes; if (fullPacketLen == readBytes) { - sif::debug << "recvd full " << fullPacketLen << std::endl; + // sif::debug << "recvd full " << fullPacketLen << std::endl; break; } usleep(usleepDelay); @@ -436,6 +445,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { usleepDelay *= 4; } } + arrayprinter::print(tmBuf.data(), readBytes); return result; } diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 820b479a..4a6e6b5c 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -375,8 +375,9 @@ class FlashFopen : public TcBase { return result; } std::memcpy(payloadStart, filename.c_str(), nameSize); - payloadStart[nameSize] = NULL_TERMINATOR; - payloadStart[255] = NULL_TERMINATOR; + // payloadStart[nameSize] = NULL_TERMINATOR; + std::memset(payloadStart + nameSize, 0, 256 - nameSize); + // payloadStart[255] = NULL_TERMINATOR; payloadStart[256] = static_cast(accessMode); return returnvalue::OK; } @@ -445,7 +446,7 @@ class TcFlashRead : public TcBase { sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl; return returnvalue::FAILED; } - spParams.setFullPayloadLen(readLen + FLASH_READ_MIN_OVERHEAD + CRC_SIZE); + spParams.setFullPayloadLen(sizeof(uint32_t) + CRC_SIZE); ReturnValue_t result = checkPayloadLen(); if (result != returnvalue::OK) { return result; From f9e8dc6e6016fee7b4514c10a1e4ef59d27ada8d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 16:33:52 +0200 Subject: [PATCH 057/172] D'OH --- linux/payload/PlocMpsocSpecialComHelper.cpp | 10 +++++----- linux/payload/plocMpsocHelpers.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 20e9acca..0d29db14 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -199,7 +199,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (terminate) { std::filesystem::remove(flashReadAndWrite.obcFile, e); // TODO: Might not be needed - flashfclose(); + // flashfclose(); return returnvalue::OK; } nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE; @@ -210,7 +210,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (ofile.bad() or not ofile.is_open()) { std::filesystem::remove(flashReadAndWrite.obcFile, e); // TODO: Might not be needed - flashfclose(); + // flashfclose(); return FILE_READ_ERROR; } mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); @@ -218,14 +218,14 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); // TODO: Might not be needed - flashfclose(); + // flashfclose(); return result; } result = flashReadRequest.finishPacket(); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); // TODO: Might not be needed - flashfclose(); + // flashfclose(); return result; } (*sequenceCount)++; @@ -233,7 +233,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); // TODO: Might not be needed - flashfclose(); + // flashfclose(); return result; } readSoFar += nextReadSize; diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 4a6e6b5c..9ed5b3f0 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -439,7 +439,7 @@ class TcFlashWrite : public TcBase { class TcFlashRead : public TcBase { public: TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount) - : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} + : TcBase(params, apid::TC_FLASHREAD, sequenceCount) {} ReturnValue_t setPayload(uint32_t readLen) { if (readLen > MAX_FLASH_READ_DATA_SIZE) { From e03df2ebca446794009570cbda0d8c87be714ffc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 17:33:14 +0200 Subject: [PATCH 058/172] almost done --- .../fsfwconfig/events/translateEvents.cpp | 7 ++- .../fsfwconfig/objects/translateObjects.cpp | 2 +- generators/bsp_hosted_events.csv | 1 + generators/bsp_q7s_events.csv | 1 + generators/events/translateEvents.cpp | 7 ++- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 7 ++- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- linux/payload/PlocMpsocHandler.cpp | 39 ++++++++++------ linux/payload/PlocMpsocHandler.h | 2 +- linux/payload/PlocMpsocSpecialComHelper.cpp | 45 +++++++------------ tmtc | 2 +- 12 files changed, 62 insertions(+), 55 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 63fee50d..9a93fe4c 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 294 translations. + * @brief Auto-generated event translation file. Contains 295 translations. * @details - * Generated on: 2023-05-15 15:20:19 + * Generated on: 2023-05-17 17:15:34 */ #include "translateEvents.h" @@ -200,6 +200,7 @@ const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH"; const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR"; const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED"; const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL"; +const char *MPSOC_READ_TIMEOUT_STRING = "MPSOC_READ_TIMEOUT"; const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF"; const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS"; const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS"; @@ -692,6 +693,8 @@ const char *translateEvents(Event event) { return MPSOC_FLASH_READ_FAILED_STRING; case (12616): return MPSOC_FLASH_READ_SUCCESSFUL_STRING; + case (12617): + return MPSOC_READ_TIMEOUT_STRING; case (12700): return TRANSITION_BACK_TO_OFF_STRING; case (12701): diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index 6ab96892..34edfa41 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 171 translations. - * Generated on: 2023-05-15 15:20:19 + * Generated on: 2023-05-17 17:15:34 */ #include "translateObjects.h" diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index 2df4aa32..9dc26e07 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -194,6 +194,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h +12617;0x3149;MPSOC_READ_TIMEOUT;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h 12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h 12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 2df4aa32..9dc26e07 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -194,6 +194,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h +12617;0x3149;MPSOC_READ_TIMEOUT;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h 12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h 12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h 12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 63fee50d..9a93fe4c 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 294 translations. + * @brief Auto-generated event translation file. Contains 295 translations. * @details - * Generated on: 2023-05-15 15:20:19 + * Generated on: 2023-05-17 17:15:34 */ #include "translateEvents.h" @@ -200,6 +200,7 @@ const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH"; const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR"; const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED"; const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL"; +const char *MPSOC_READ_TIMEOUT_STRING = "MPSOC_READ_TIMEOUT"; const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF"; const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS"; const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS"; @@ -692,6 +693,8 @@ const char *translateEvents(Event event) { return MPSOC_FLASH_READ_FAILED_STRING; case (12616): return MPSOC_FLASH_READ_SUCCESSFUL_STRING; + case (12617): + return MPSOC_READ_TIMEOUT_STRING; case (12700): return TRANSITION_BACK_TO_OFF_STRING; case (12701): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 458e8d67..eb2125b4 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 175 translations. - * Generated on: 2023-05-15 15:20:19 + * Generated on: 2023-05-17 17:15:34 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 63fee50d..9a93fe4c 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 294 translations. + * @brief Auto-generated event translation file. Contains 295 translations. * @details - * Generated on: 2023-05-15 15:20:19 + * Generated on: 2023-05-17 17:15:34 */ #include "translateEvents.h" @@ -200,6 +200,7 @@ const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH"; const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR"; const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED"; const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL"; +const char *MPSOC_READ_TIMEOUT_STRING = "MPSOC_READ_TIMEOUT"; const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF"; const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS"; const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS"; @@ -692,6 +693,8 @@ const char *translateEvents(Event event) { return MPSOC_FLASH_READ_FAILED_STRING; case (12616): return MPSOC_FLASH_READ_SUCCESSFUL_STRING; + case (12617): + return MPSOC_READ_TIMEOUT_STRING; case (12700): return TRANSITION_BACK_TO_OFF_STRING; case (12701): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 458e8d67..eb2125b4 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 175 translations. - * Generated on: 2023-05-15 15:20:19 + * Generated on: 2023-05-17 17:15:34 */ #include "translateObjects.h" diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 750b64d7..00b0081e 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -53,15 +53,26 @@ ReturnValue_t PlocMpsocHandler::initialize() { if (result != returnvalue::OK) { return result; } - result = manager->subscribeToEventRange( - eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_FAILED), + result = manager->subscribeToEvent( + eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_FAILED)); + if (result != returnvalue::OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->subscribeToEvent( + eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_SUCCESSFUL)); if (result != returnvalue::OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from " - " ploc mpsoc helper" - << std::endl; -#endif + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->subscribeToEvent( + eventQueue->getId(), + event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_READ_SUCCESSFUL)); + if (result != returnvalue::OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + result = manager->subscribeToEvent( + eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_READ_FAILED)); + if (result != returnvalue::OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -125,7 +136,7 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI } } - if (plocMPSoCHelperExecuting) { + if (specialComHelperExecuting) { return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING; } @@ -141,7 +152,7 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } - plocMPSoCHelperExecuting = true; + specialComHelperExecuting = true; return EXECUTION_FINISHED; } case mpsoc::TC_FLASH_READ_FULL_FILE: { @@ -156,7 +167,7 @@ ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueI if (result != returnvalue::OK) { return result; } - plocMPSoCHelperExecuting = true; + specialComHelperExecuting = true; return EXECUTION_FINISHED; } case (mpsoc::OBSW_RESET_SEQ_COUNT): { @@ -241,12 +252,12 @@ void PlocMpsocHandler::doShutDown() { setMode(_MODE_POWER_DOWN); commandIsPending = false; sequenceCount = 0; - plocMPSoCHelperExecuting = false; + specialComHelperExecuting = false; startupState = StartupState::IDLE; } ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if (not commandIsPending and not plocMPSoCHelperExecuting) { + if (not commandIsPending and not specialComHelperExecuting) { *id = mpsoc::TC_GET_HK_REPORT; commandIsPending = true; cmdCountdown.resetTimer(); @@ -548,7 +559,7 @@ void PlocMpsocHandler::handleEvent(EventMessage* eventMessage) { object_id_t objectId = eventMessage->getReporter(); switch (objectId) { case objects::PLOC_MPSOC_HELPER: { - plocMPSoCHelperExecuting = false; + specialComHelperExecuting = false; break; } default: @@ -1209,7 +1220,7 @@ size_t PlocMpsocHandler::getNextReplyLength(DeviceCommandId_t commandId) { ReturnValue_t PlocMpsocHandler::doSendReadHook() { // Prevent DHB from polling UART during commands executed by the mpsoc helper task - if (plocMPSoCHelperExecuting) { + if (specialComHelperExecuting) { return returnvalue::FAILED; } return returnvalue::OK; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index e0474a33..a82623b0 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -168,7 +168,7 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { CommandActionHelper commandActionHelper; // Used to block incoming commands when MPSoC helper class is currently executing a command - bool plocMPSoCHelperExecuting = false; + bool specialComHelperExecuting = false; bool commandIsPending = false; struct TmMemReadReport { diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 0d29db14..6ab20802 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -140,7 +140,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { size_t bytesRead = 0; while (remainingSize > 0) { if (terminate) { - flashfclose(); return returnvalue::OK; } if (remainingSize > mpsoc::SP_MAX_DATA_SIZE) { @@ -149,7 +148,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { dataLength = remainingSize; } if (file.bad() or not file.is_open()) { - flashfclose(); return FILE_WRITE_ERROR; } file.seekg(bytesRead, file.beg); @@ -159,18 +157,15 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { mpsoc::TcFlashWrite tc(spParams, *sequenceCount); result = tc.setPayload(fileBuf.data(), dataLength); if (result != returnvalue::OK) { - flashfclose(); return result; } result = tc.finishPacket(); if (result != returnvalue::OK) { - flashfclose(); return result; } (*sequenceCount)++; result = handlePacketTransmissionNoReply(tc); if (result != returnvalue::OK) { - flashfclose(); return result; } } @@ -198,8 +193,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { while (readSoFar < flashReadAndWrite.totalReadSize) { if (terminate) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - // TODO: Might not be needed - // flashfclose(); return returnvalue::OK; } nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE; @@ -209,35 +202,31 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { sif::debug << "reading " << nextReadSize << " bytes from offset " << readSoFar << std::endl; if (ofile.bad() or not ofile.is_open()) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - // TODO: Might not be needed - // flashfclose(); return FILE_READ_ERROR; } mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount); result = flashReadRequest.setPayload(nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - // TODO: Might not be needed - // flashfclose(); return result; } result = flashReadRequest.finishPacket(); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - // TODO: Might not be needed - // flashfclose(); return result; } (*sequenceCount)++; result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); - // TODO: Might not be needed - // flashfclose(); return result; } readSoFar += nextReadSize; } + result = flashfclose(); + if (result != returnvalue::OK) { + return result; + } sif::debug << "read file done" << std::endl; return result; } @@ -299,10 +288,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc if (result != returnvalue::OK) { return result; } - result = handleTmReception(); - if (result != returnvalue::OK) { - return result; - } return handleExe(); } else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) { handleExeFailure(); @@ -346,14 +331,13 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleAck() { if (result != returnvalue::OK) { return result; } - SpTmReader tmPacket(tmBuf.data(), tmBuf.size()); result = checkReceivedTm(); if (result != returnvalue::OK) { return result; } - uint16_t apid = tmPacket.getApid(); + uint16_t apid = spReader.getApid(); if (apid != mpsoc::apid::ACK_SUCCESS) { - handleAckApidFailure(tmPacket); + handleAckApidFailure(spReader); return returnvalue::FAILED; } return returnvalue::OK; @@ -464,14 +448,15 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofi const uint8_t* packetData = spReader.getPacketData(); size_t deserDummy = spReader.getPacketDataLen() - mpsoc::CRC_SIZE; uint32_t receivedReadLen = 0; - std::string receivedShortName = std::string(reinterpret_cast(packetData), 12); - if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 12)) { - sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and " - "received file name" - << std::endl; - triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_FILENAME_ERROR); - return returnvalue::FAILED; - } + // I think this is buggy.. + // std::string receivedShortName = std::string(reinterpret_cast(packetData), 12); + // if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 11)) { + // sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and " + // "received file name" + // << std::endl; + // triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_FILENAME_ERROR); + // return returnvalue::FAILED; + // } packetData += 12; result = SerializeAdapter::deSerialize(&receivedReadLen, &packetData, &deserDummy, SerializeIF::Endianness::NETWORK); diff --git a/tmtc b/tmtc index b8e1c7af..6ec0ce20 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit b8e1c7afe91bddfea2b139217320033f3a3b0efb +Subproject commit 6ec0ce20fa98877c9f88acb5fe9129254291344b From 7f115303aed65d350ed8a58c3fa6d8ef83d9aab7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 18:33:48 +0200 Subject: [PATCH 059/172] everything is working now --- linux/payload/PlocMpsocSpecialComHelper.cpp | 22 +++++++----------- linux/payload/PlocMpsocSpecialComHelper.h | 2 +- linux/payload/plocMpsocHelpers.cpp | 4 ++++ linux/payload/plocMpsocHelpers.h | 25 ++++++++++++--------- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index 6ab20802..acf88abd 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -128,7 +128,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { if (file.bad()) { return returnvalue::FAILED; } - result = flashfopen(mpsoc::FileAccessMode::WRITE); + result = flashfopen(mpsoc::FileAccessModes::WRITE | mpsoc::FileAccessModes::OPEN_ALWAYS); if (result != returnvalue::OK) { return result; } @@ -142,8 +142,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { if (terminate) { return returnvalue::OK; } - if (remainingSize > mpsoc::SP_MAX_DATA_SIZE) { - dataLength = mpsoc::SP_MAX_DATA_SIZE; + // The minus 4 is necessary for unknown reasons. Maybe some bug in the ILH software? + if (remainingSize > mpsoc::MAX_FLASH_WRITE_DATA_SIZE - 4) { + dataLength = mpsoc::MAX_FLASH_WRITE_DATA_SIZE - 4; } else { dataLength = remainingSize; } @@ -177,13 +178,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { } ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { - sif::debug << "performing flash read" << std::endl; std::error_code e; std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary); if (ofile.bad()) { return returnvalue::FAILED; } - ReturnValue_t result = flashfopen(mpsoc::FileAccessMode::READ); + ReturnValue_t result = flashfopen(mpsoc::FileAccessModes::READ); if (result != returnvalue::OK) { std::filesystem::remove(flashReadAndWrite.obcFile, e); return result; @@ -199,7 +199,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (flashReadAndWrite.totalReadSize - readSoFar < mpsoc::MAX_FLASH_READ_DATA_SIZE) { nextReadSize = flashReadAndWrite.totalReadSize - readSoFar; } - sif::debug << "reading " << nextReadSize << " bytes from offset " << readSoFar << std::endl; if (ofile.bad() or not ofile.is_open()) { std::filesystem::remove(flashReadAndWrite.obcFile, e); return FILE_READ_ERROR; @@ -227,11 +226,10 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { if (result != returnvalue::OK) { return result; } - sif::debug << "read file done" << std::endl; return result; } -ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(mpsoc::FileAccessMode mode) { +ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) { spParams.buf = commandBuffer; mpsoc::FlashFopen flashFopen(spParams, *sequenceCount); ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode); @@ -314,8 +312,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t result = returnvalue::OK; - sif::debug << "sending TC" << std::endl; - arrayprinter::print(tc.getFullPacket(), tc.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen()); if (result != returnvalue::OK) { sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; @@ -412,7 +408,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { usleepDelay *= 4; } } - // sif::debug << "recvd first 6 bytes" << std::endl; while (true) { if (tmCountdown.hasTimedOut()) { triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs()); @@ -421,7 +416,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, ¤tBytes); readBytes += currentBytes; if (fullPacketLen == readBytes) { - // sif::debug << "recvd full " << fullPacketLen << std::endl; break; } usleep(usleepDelay); @@ -429,7 +423,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { usleepDelay *= 4; } } - arrayprinter::print(tmBuf.data(), readBytes); + // arrayprinter::print(tmBuf.data(), readBytes); return result; } @@ -448,7 +442,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofi const uint8_t* packetData = spReader.getPacketData(); size_t deserDummy = spReader.getPacketDataLen() - mpsoc::CRC_SIZE; uint32_t receivedReadLen = 0; - // I think this is buggy.. + // I think this is buggy, weird stuff in the short name field. // std::string receivedShortName = std::string(reinterpret_cast(packetData), 12); // if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 11)) { // sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and " diff --git a/linux/payload/PlocMpsocSpecialComHelper.h b/linux/payload/PlocMpsocSpecialComHelper.h index 4b829c63..bc6bec8c 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.h +++ b/linux/payload/PlocMpsocSpecialComHelper.h @@ -179,7 +179,7 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF void resetHelper(); ReturnValue_t performFlashWrite(); ReturnValue_t performFlashRead(); - ReturnValue_t flashfopen(mpsoc::FileAccessMode mode); + ReturnValue_t flashfopen(uint8_t accessMode); ReturnValue_t flashfclose(); ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc); ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc, std::ofstream& ofile, diff --git a/linux/payload/plocMpsocHelpers.cpp b/linux/payload/plocMpsocHelpers.cpp index ab6f0907..9e5b11c9 100644 --- a/linux/payload/plocMpsocHelpers.cpp +++ b/linux/payload/plocMpsocHelpers.cpp @@ -33,6 +33,10 @@ std::string mpsoc::getStatusString(uint16_t status) { return "Flash mount failed"; break; } + case (mpsoc::status_code::FLASH_FILE_ALREADY_OPEN): { + return "Flash file already open"; + break; + } case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): { return "Flash file already closed"; break; diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 9ed5b3f0..6d42e6c6 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -13,12 +13,16 @@ namespace mpsoc { -enum FileAccessMode : uint8_t { +enum FileAccessModes : uint8_t { + // Opens a file, fails if the file does not exist. OPEN_EXISTING = 0x00, READ = 0x01, WRITE = 0x02, + // Creates a new file, fails if it already exists. CREATE_NEW = 0x04, + // Creates a new file, existing file is truncated and overwritten. CREATE_ALWAYS = 0x08, + // Opens the file if it is existing. If not, a new file is created. OPEN_ALWAYS = 0x10, OPEN_APPEND = 0x30 }; @@ -182,6 +186,8 @@ static constexpr size_t SP_MAX_DATA_SIZE = SP_MAX_SIZE - ccsds::HEADER_LEN - CRC static constexpr size_t FLASH_READ_MIN_OVERHEAD = 16; // 1000 bytes. static const size_t MAX_FLASH_READ_DATA_SIZE = SP_MAX_DATA_SIZE - FLASH_READ_MIN_OVERHEAD; +// 1012 bytes, 4 bytes for the write length. +static constexpr size_t MAX_FLASH_WRITE_DATA_SIZE = SP_MAX_DATA_SIZE - sizeof(uint32_t); /** * The replay write sequence command has a maximum delay for the execution report which amounts to @@ -204,7 +210,7 @@ static const uint16_t TC_EXEUTION_DISABLED = 0x5E2; static const uint16_t FLASH_MOUNT_FAILED = 0x5E3; static const uint16_t FLASH_FILE_ALREADY_CLOSED = 0x5E4; static const uint16_t FLASH_FILE_OPEN_FAILED = 0x5E5; -static const uint16_t FLASH_FILE_ALREDY_OPEN = 0x5E6; +static const uint16_t FLASH_FILE_ALREADY_OPEN = 0x5E6; static const uint16_t FLASH_FILE_NOT_OPEN = 0x5E7; static const uint16_t FLASH_UNMOUNT_FAILED = 0x5E8; static const uint16_t HEAP_ALLOCATION_FAILED = 0x5E9; @@ -366,7 +372,7 @@ class FlashFopen : public TcBase { FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} - ReturnValue_t setPayload(std::string filename, FileAccessMode mode) { + ReturnValue_t setPayload(std::string filename, uint8_t mode) { accessMode = mode; size_t nameSize = filename.size(); spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE); @@ -378,12 +384,12 @@ class FlashFopen : public TcBase { // payloadStart[nameSize] = NULL_TERMINATOR; std::memset(payloadStart + nameSize, 0, 256 - nameSize); // payloadStart[255] = NULL_TERMINATOR; - payloadStart[256] = static_cast(accessMode); + payloadStart[256] = accessMode; return returnvalue::OK; } private: - FileAccessMode accessMode = FileAccessMode::OPEN_EXISTING; + uint8_t accessMode = FileAccessModes::OPEN_EXISTING; }; /** @@ -406,14 +412,13 @@ class TcFlashWrite : public TcBase { : TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {} ReturnValue_t setPayload(const uint8_t* writeData, uint32_t writeLen_) { - ReturnValue_t result = returnvalue::OK; writeLen = writeLen_; - if (writeLen > SP_MAX_DATA_SIZE) { + if (writeLen > MAX_FLASH_WRITE_DATA_SIZE) { sif::error << "TcFlashWrite: Command data too big" << std::endl; return returnvalue::FAILED; } - spParams.setFullPayloadLen(static_cast(writeLen) + 4 + CRC_SIZE); - result = checkPayloadLen(); + spParams.setFullPayloadLen(sizeof(uint32_t) + static_cast(writeLen) + CRC_SIZE); + ReturnValue_t result = checkPayloadLen(); if (result != returnvalue::OK) { return result; } @@ -423,7 +428,7 @@ class TcFlashWrite : public TcBase { if (result != returnvalue::OK) { return result; } - std::memcpy(payloadStart + sizeof(writeLen), writeData, writeLen); + std::memcpy(payloadStart + sizeof(uint32_t), writeData, writeLen); updateSpFields(); result = checkSizeAndSerializeHeader(); if (result != returnvalue::OK) { From b9afeb9c19e5dcd7e0fd34b8c00050a9c5c62bd8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 18:44:12 +0200 Subject: [PATCH 060/172] fix some regressions --- linux/payload/PlocMpsocHandler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 00b0081e..cdf59c52 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -654,6 +654,10 @@ ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() { ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount); + ReturnValue_t result = tcReplayWriteSeq.setPayload(commandData, commandDataLen); + if (result != returnvalue::OK) { + return result; + } finishTcPrep(tcReplayWriteSeq); return returnvalue::OK; } @@ -673,6 +677,10 @@ ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() { ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount); + ReturnValue_t result = tcCamCmdSend.setPayload(commandData, commandDataLen); + if (result != returnvalue::OK) { + return result; + } finishTcPrep(tcCamCmdSend); nextReplyId = mpsoc::TM_CAM_CMD_RPT; return returnvalue::OK; @@ -681,6 +689,10 @@ ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData, ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen) { mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); + ReturnValue_t result = tcCamTakePic.setPayload(commandData, commandDataLen); + if (result != returnvalue::OK) { + return result; + } finishTcPrep(tcCamTakePic); return returnvalue::OK; } From d28bc3f74ddbcf8a4f79738fee8144290b857e23 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 18:51:53 +0200 Subject: [PATCH 061/172] bugfix --- linux/payload/plocMpsocHelpers.h | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 6d42e6c6..c9b08a28 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -878,7 +878,6 @@ class TcCamcmdSend : public TcBase { TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount) : TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {} - protected: ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { if (commandDataLen > MAX_DATA_LENGTH) { return INVALID_LENGTH; From a0e305fe1f923fe3d8a1ca548a3324ea7c9a04bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 May 2023 18:55:53 +0200 Subject: [PATCH 062/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3924f1..586c497f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ will consitute of a breaking change warranting a new major release: ## Added - Add the remaining system modes. +- PLOC MPSoC flash read command working. ## Fixed @@ -62,6 +63,7 @@ will consitute of a breaking change warranting a new major release: - Fixed correction for `GPS Altitude` in case the sensor data is out of the expected bonds. - PLOC MPSoC special communication is now scheduled, which allows flash read and flash write commands to work. +- Fixed the MPSoC flash write command. # [v2.0.5] 2023-05-11 From ed74367f01d37a2684d0a5ee9dd9b0b5ede30dbd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 19 May 2023 09:41:44 +0200 Subject: [PATCH 063/172] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c3924f1..119205b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,9 @@ will consitute of a breaking change warranting a new major release: - Larger allowed path and file sizes for STR and PLOC MPSoC modules. - More robust MPSoC flash read and write command data handling. - Increase frequency of payload handlers from 0.8 seconds to 0.5 seconds. +- Disable missed deadlines per default. Not useful in orbit, and triggers all the time on the EM + build after a number of subsequent runs, without any apparent reason (deadlines are not actually + missed, thread usage displayed is nominal) ## Added From cd514e81250d78a268d73865298eb6e1d1434fca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 May 2023 11:40:33 +0200 Subject: [PATCH 064/172] ze batteri wos add --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2a9482e..b5ecf173 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,8 @@ set(OBSW_ADD_MGT ${INIT_VAL} CACHE STRING "Add MGT module") set(OBSW_ADD_BPX_BATTERY_HANDLER - ${INIT_VAL} - CACHE STRING "Add MGT module") + 1 + CACHE STRING "Add BPX battery module") set(OBSW_ADD_STAR_TRACKER ${INIT_VAL} CACHE STRING "Add Startracker module") From d23082283dd1e53c4c7b04560e95f6d53c304ab8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 May 2023 11:42:08 +0200 Subject: [PATCH 065/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7ed6681..13c81828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ will consitute of a breaking change warranting a new major release: - Add the remaining system modes. - PLOC MPSoC flash read command working. +- BPX battery handler is added for EM by default. ## Fixed From 2543cdf5b7b67ea97af31704a2fff7d241312ba2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 22 May 2023 11:44:42 +0200 Subject: [PATCH 066/172] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8841cd0c..3ab6a184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ will consitute of a breaking change warranting a new major release: # [v2.2.0] to be released +- eive-tmtc: v4.0.0 (to be released) + +## Fixed + +- CFDP low level protocol bugfix. Requires fsfw update and tmtc update. + # [v2.1.0] to be released ## Changed From 9ff154cedce3daf02592243dd51adbc50088883d Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 23 May 2023 14:56:04 +0200 Subject: [PATCH 067/172] added missing parameter --- mission/controller/acs/AcsParameters.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 03500cc3..53f25bb1 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -539,6 +539,9 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, case 0xA: parameterWrapper->setVector(nadirModeControllerParameters.quatRef); break; + case 0xB: + parameterWrapper->setVector(nadirModeControllerParameters.refRotRate); + break; case 0xC: parameterWrapper->set(nadirModeControllerParameters.timeElapsedMax); break; From 5390e947cae6a4e966f0874715b219afc00dec57 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 23 May 2023 15:02:35 +0200 Subject: [PATCH 068/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7ed6681..a85086a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ will consitute of a breaking change warranting a new major release: - PLOC MPSoC special communication is now scheduled, which allows flash read and flash write commands to work. - Fixed the MPSoC flash write command. +- Added missing ACS parameter. # [v2.0.5] 2023-05-11 From 62ae7ff48296e3d3bd75524171c4371989cd0701 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 23 May 2023 15:04:43 +0200 Subject: [PATCH 069/172] frmt --- mission/controller/acs/AcsParameters.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 53f25bb1..e9ba7c3a 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -540,8 +540,8 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->setVector(nadirModeControllerParameters.quatRef); break; case 0xB: - parameterWrapper->setVector(nadirModeControllerParameters.refRotRate); - break; + parameterWrapper->setVector(nadirModeControllerParameters.refRotRate); + break; case 0xC: parameterWrapper->set(nadirModeControllerParameters.timeElapsedMax); break; From 32a4aa48d9936dfa1d50208f41242886572ed243 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 23 May 2023 15:07:23 +0200 Subject: [PATCH 070/172] frmt --- mission/controller/acs/AcsParameters.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index e9ba7c3a..792a72ec 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -540,8 +540,8 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, parameterWrapper->setVector(nadirModeControllerParameters.quatRef); break; case 0xB: - parameterWrapper->setVector(nadirModeControllerParameters.refRotRate); - break; + parameterWrapper->setVector(nadirModeControllerParameters.refRotRate); + break; case 0xC: parameterWrapper->set(nadirModeControllerParameters.timeElapsedMax); break; From 7ac2271eabb6041b636a3430e4800d9124a80d4e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 19:12:35 +0200 Subject: [PATCH 071/172] buuuug --- bsp_q7s/core/ObjectFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 17b14b56..cea90bf2 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -805,7 +805,7 @@ ReturnValue_t ObjectFactory::createCcsdsComponents(CcsdsComponentArgs& args) { // Core task which handles the HK store and takes care of dumping it as TM using a VC directly auto* hkStore = new PersistentSingleTmStoreTask( objects::HK_STORE_AND_TM_TASK, args.ipcStore, *args.stores.hkStore, *vc, - persTmStore::DUMP_HK_STORE_DONE, persTmStore::DUMP_HK_STORE_DONE, *SdCardManager::instance(), + persTmStore::DUMP_HK_STORE_DONE, persTmStore::DUMP_HK_CANCELLED, *SdCardManager::instance(), PTME_LOCKED); hkStore->connectModeTreeParent(satsystem::com::SUBSYSTEM); From 6bfb0d4fb058b3afe20e7d01b5b21e14cb921ede Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 19:14:03 +0200 Subject: [PATCH 072/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c81828..cc74f261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ will consitute of a breaking change warranting a new major release: - PLOC MPSoC special communication is now scheduled, which allows flash read and flash write commands to work. - Fixed the MPSoC flash write command. +- HK TM store: The HK store dump success event was triggered for cancelled HK dumps. # [v2.0.5] 2023-05-11 From 722247598598a1cdb3a7ee2e8607009ab5c43202 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 19:18:42 +0200 Subject: [PATCH 073/172] changelog, remove unnecessary logic --- CHANGELOG.md | 3 +++ mission/com/TmStoreTaskBase.cpp | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f36fc3aa..4073d7fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,9 @@ TODO: New firmware package version. - Disable missed deadlines per default. Not useful in orbit, and triggers all the time on the EM build after a number of subsequent runs, without any apparent reason (deadlines are not actually missed, thread usage displayed is nominal) +- TM store dumpes will not be cancelled anymore if the transmitter is off. The dump can be cancelled + with an OFF command, and the PTME is perfectly capable of dumping without the transmitter being + on. ## Added diff --git a/mission/com/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp index 6598225d..5efb40bf 100644 --- a/mission/com/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -39,6 +39,7 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, } // Dump TMs if (store.getState() == PersistentTmStore::State::DUMPING) { + sif::debug << "handling dump" << std::endl; if (handleOneDump(store, dumpContext, dumpPerformed) != returnvalue::OK) { return result; } @@ -94,13 +95,6 @@ void TmStoreTaskBase::cancelDump(DumpContext& ctx, PersistentTmStore& store, boo ReturnValue_t TmStoreTaskBase::handleOneDump(PersistentTmStoreWithTmQueue& store, DumpContext& dumpContext, bool& dumpPerformed) { ReturnValue_t result = returnvalue::OK; - // The PTME might have been reset an transmitter state change, so there is no point in continuing - // the dump. - // TODO: Will be solved in a cleaner way, this is kind of a hack. - if (not channel.isTxOn()) { - cancelDump(dumpContext, store, false); - return returnvalue::FAILED; - } // It is assumed that the PTME will only be locked for a short period (e.g. to change datarate). if (not channel.isBusy() and not ptmeLocked) { performDump(store, dumpContext, dumpPerformed); From 28beb006b2c39792eb4f158916027a473469f857 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 19:37:01 +0200 Subject: [PATCH 074/172] thats an annoying bug --- CHANGELOG.md | 2 ++ mission/com/TmStoreTaskBase.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c81828..c7997dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ will consitute of a breaking change warranting a new major release: - PLOC MPSoC special communication is now scheduled, which allows flash read and flash write commands to work. - Fixed the MPSoC flash write command. +- When a PUS parsing error occured while parsing a TM store file, the dump completion procedure + was always executed. # [v2.0.5] 2023-05-11 diff --git a/mission/com/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp index 6598225d..0d3da770 100644 --- a/mission/com/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -140,7 +140,7 @@ ReturnValue_t TmStoreTaskBase::performDump(PersistentTmStoreWithTmQueue& store, ReturnValue_t result = store.getNextDumpPacket(tmReader, fileHasSwapped); if (result != returnvalue::OK) { sif::error << "PersistentTmStore: Getting next dump packet failed" << std::endl; - } else if (fileHasSwapped or result == PersistentTmStore::DUMP_DONE) { + } else if (fileHasSwapped and result == PersistentTmStore::DUMP_DONE) { // This can happen if a file is corrupted and the next file swap completes the dump. dumpDoneHandler(); return returnvalue::OK; From 50327fb6148d25b1e8fb28a692a3cc5e72767b0d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 19:44:06 +0200 Subject: [PATCH 075/172] get rid of the printouts and of the delay --- mission/com/PersistentLogTmStoreTask.cpp | 2 +- mission/com/PersistentSingleTmStoreTask.cpp | 2 +- mission/com/TmStoreTaskBase.cpp | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mission/com/PersistentLogTmStoreTask.cpp b/mission/com/PersistentLogTmStoreTask.cpp index 77f2bb7d..0d47e50f 100644 --- a/mission/com/PersistentLogTmStoreTask.cpp +++ b/mission/com/PersistentLogTmStoreTask.cpp @@ -48,7 +48,7 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { } else { // TODO: Would be best to remove this, but not delaying here can lead to evil issues. // Polling the PAPB of the PTME core too often leads to scheuduling issues. - TaskFactory::delayTask(2); + // TaskFactory::delayTask(2); } } } diff --git a/mission/com/PersistentSingleTmStoreTask.cpp b/mission/com/PersistentSingleTmStoreTask.cpp index 1b77365b..2afc8e31 100644 --- a/mission/com/PersistentSingleTmStoreTask.cpp +++ b/mission/com/PersistentSingleTmStoreTask.cpp @@ -30,7 +30,7 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { } else { // TODO: Would be best to remove this, but not delaying here can lead to evil issues. // Polling the PAPB of the PTME core too often leads to scheuduling issues. - TaskFactory::delayTask(2); + // TaskFactory::delayTask(2); } } } diff --git a/mission/com/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp index f7257f23..2158cf2a 100644 --- a/mission/com/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -39,7 +39,6 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store, } // Dump TMs if (store.getState() == PersistentTmStore::State::DUMPING) { - sif::debug << "handling dump" << std::endl; if (handleOneDump(store, dumpContext, dumpPerformed) != returnvalue::OK) { return result; } From 303df55a1298a5c027a521c3a9fb8604bd3d266b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 20:10:52 +0200 Subject: [PATCH 076/172] always dump data into the VC --- mission/com/VirtualChannel.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mission/com/VirtualChannel.cpp b/mission/com/VirtualChannel.cpp index 8e225674..ea5527a8 100644 --- a/mission/com/VirtualChannel.cpp +++ b/mission/com/VirtualChannel.cpp @@ -11,10 +11,7 @@ ReturnValue_t VirtualChannel::sendNextTm(const uint8_t* data, size_t size) { } ReturnValue_t VirtualChannel::write(const uint8_t* data, size_t size) { - if (txOn) { - return ptme.writeToVc(vcId, data, size); - } - return returnvalue::OK; + return ptme.writeToVc(vcId, data, size); } uint8_t VirtualChannel::getVcid() const { return vcId; } @@ -22,10 +19,6 @@ uint8_t VirtualChannel::getVcid() const { return vcId; } const char* VirtualChannel::getName() const { return vcName.c_str(); } bool VirtualChannel::isBusy() const { - // Data is discarded, so channel is not busy. - if (not txOn) { - return false; - } return ptme.isBusy(vcId); } From 042b8fb3c324ccab5ba56bf9d03980b7b091a456 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 20:13:02 +0200 Subject: [PATCH 077/172] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c81828..8890ad7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,9 @@ will consitute of a breaking change warranting a new major release: - Disable missed deadlines per default. Not useful in orbit, and triggers all the time on the EM build after a number of subsequent runs, without any apparent reason (deadlines are not actually missed, thread usage displayed is nominal) +- Transmitter state is not taken into account anymore for writing into the PTME. The PTME should + be perfectly capable of generating a valid CADU, even when the transmitter is not ON for any + reason. ## Added From 266abad3b3a63efb1b2c45c287e335a13545c9a2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 May 2023 20:15:36 +0200 Subject: [PATCH 078/172] no dump cancel on TX OFF --- CHANGELOG.md | 3 +++ mission/com/TmStoreTaskBase.cpp | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13c81828..b021a184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,9 @@ will consitute of a breaking change warranting a new major release: - Disable missed deadlines per default. Not useful in orbit, and triggers all the time on the EM build after a number of subsequent runs, without any apparent reason (deadlines are not actually missed, thread usage displayed is nominal) +- TM store dumpes will not be cancelled anymore if the transmitter is off. The dump can be cancelled + with an OFF command, and the PTME is perfectly capable of dumping without the transmitter being + on. ## Added diff --git a/mission/com/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp index 6598225d..c8abbae8 100644 --- a/mission/com/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -94,13 +94,6 @@ void TmStoreTaskBase::cancelDump(DumpContext& ctx, PersistentTmStore& store, boo ReturnValue_t TmStoreTaskBase::handleOneDump(PersistentTmStoreWithTmQueue& store, DumpContext& dumpContext, bool& dumpPerformed) { ReturnValue_t result = returnvalue::OK; - // The PTME might have been reset an transmitter state change, so there is no point in continuing - // the dump. - // TODO: Will be solved in a cleaner way, this is kind of a hack. - if (not channel.isTxOn()) { - cancelDump(dumpContext, store, false); - return returnvalue::FAILED; - } // It is assumed that the PTME will only be locked for a short period (e.g. to change datarate). if (not channel.isBusy() and not ptmeLocked) { performDump(store, dumpContext, dumpPerformed); From ee0646caf140373c6f1132718fa8f5d767120cb9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 May 2023 11:04:07 +0200 Subject: [PATCH 079/172] enable IMTQ HK sets --- bsp_q7s/em/emObjectFactory.cpp | 2 +- dummies/ImtqDummy.cpp | 40 ++++++++++++++++++++++++++++++++-- dummies/ImtqDummy.h | 26 +++++++++++++++++++++- dummies/helperFactory.cpp | 6 +++-- dummies/helperFactory.h | 2 +- 5 files changed, 69 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 36863b89..59660b86 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -79,7 +79,7 @@ void ObjectFactory::produce(void* args) { #endif satsystem::EIVE_SYSTEM.setI2cRecoveryParams(pwrSwitcher); - dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF); + dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF, enableHkSets); new CoreController(objects::CORE_CONTROLLER, enableHkSets); diff --git a/dummies/ImtqDummy.cpp b/dummies/ImtqDummy.cpp index b2f61bb3..8f8d1513 100644 --- a/dummies/ImtqDummy.cpp +++ b/dummies/ImtqDummy.cpp @@ -2,8 +2,12 @@ #include -ImtqDummy::ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) - : DeviceHandlerBase(objectId, comif, comCookie) {} +ImtqDummy::ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, + bool enableHkSets) + : DeviceHandlerBase(objectId, comif, comCookie), + setNoTorque(this), + setWithTorque(this), + enableHkSets(enableHkSets) {} ImtqDummy::~ImtqDummy() = default; @@ -45,5 +49,37 @@ ReturnValue_t ImtqDummy::initializeLocalDataPool(localpool::DataPool &localDataP localDataPoolMap.emplace(imtq::ACTUATION_RAW_STATUS, new PoolEntry({0})); localDataPoolMap.emplace(imtq::DIPOLES_ID, new PoolEntry({0, 0, 0})); localDataPoolMap.emplace(imtq::CURRENT_TORQUE_DURATION, new PoolEntry({0})); + + // ENG HK No Torque + localDataPoolMap.emplace(imtq::DIGITAL_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::ANALOG_VOLTAGE_MV, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::DIGITAL_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::ANALOG_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::COIL_CURRENTS, &coilCurrentsMilliampsNoTorque); + localDataPoolMap.emplace(imtq::COIL_TEMPERATURES, &coilTempsNoTorque); + localDataPoolMap.emplace(imtq::MCU_TEMPERATURE, new PoolEntry({0})); + + // ENG HK With Torque + localDataPoolMap.emplace(imtq::DIGITAL_VOLTAGE_MV_WT, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::ANALOG_VOLTAGE_MV_WT, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::DIGITAL_CURRENT_WT, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::ANALOG_CURRENT_WT, new PoolEntry({0})); + localDataPoolMap.emplace(imtq::COIL_CURRENTS_WT, &coilCurrentsMilliampsWithTorque); + localDataPoolMap.emplace(imtq::COIL_TEMPERATURES_WT, &coilTempsWithTorque); + localDataPoolMap.emplace(imtq::MCU_TEMPERATURE_WT, new PoolEntry({0})); + + poolManager.subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams(setNoTorque.getSid(), enableHkSets, 30.0)); + poolManager.subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams(setWithTorque.getSid(), enableHkSets, 30.0)); return DeviceHandlerBase::initializeLocalDataPool(localDataPoolMap, poolManager); } + +LocalPoolDataSetBase *ImtqDummy::getDataSetHandle(sid_t sid) { + if (sid == setNoTorque.getSid()) { + return &setNoTorque; + } else if (sid == setWithTorque.getSid()) { + return &setWithTorque; + } + return nullptr; +} diff --git a/dummies/ImtqDummy.h b/dummies/ImtqDummy.h index 0cfdf518..5a1de175 100644 --- a/dummies/ImtqDummy.h +++ b/dummies/ImtqDummy.h @@ -3,6 +3,8 @@ #include +#include "mission/acs/imtqHelpers.h" + class ImtqDummy : public DeviceHandlerBase { public: static const DeviceCommandId_t SIMPLE_COMMAND = 1; @@ -11,10 +13,31 @@ class ImtqDummy : public DeviceHandlerBase { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, bool enableHkSets); ~ImtqDummy() override; protected: + imtq::HkDatasetNoTorque setNoTorque; + imtq::HkDatasetWithTorque setWithTorque; + bool enableHkSets; + + PoolEntry statusMode = PoolEntry({0}); + PoolEntry statusError = PoolEntry({0}); + PoolEntry statusConfig = PoolEntry({0}); + PoolEntry statusUptime = PoolEntry({0}); + + PoolEntry mgmCalEntry = PoolEntry(3); + PoolEntry dipolesPoolEntry = PoolEntry({0, 0, 0}, false); + PoolEntry torqueDurationEntry = PoolEntry({0}, false); + PoolEntry coilCurrentsMilliampsNoTorque = PoolEntry(3); + PoolEntry coilCurrentsMilliampsWithTorque = PoolEntry(3); + PoolEntry coilTempsNoTorque = PoolEntry(3); + PoolEntry coilTempsWithTorque = PoolEntry(3); + PoolEntry mtmRawNoTorque = PoolEntry(3); + PoolEntry actStatusNoTorque = PoolEntry(1); + PoolEntry mtmRawWithTorque = PoolEntry(3); + PoolEntry actStatusWithTorque = PoolEntry(1); + void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; @@ -28,6 +51,7 @@ class ImtqDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; }; #endif /* DUMMIES_IMTQDUMMY_H_ */ diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index d7fdafbd..90a50160 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -42,7 +42,8 @@ #include "mission/system/tree/payloadModeTree.h" #include "mission/tcs/defs.h" -void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpioIF) { +void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpioIF, + bool enableHkSets) { new ComIFDummy(objects::DUMMY_COM_IF); auto* comCookieDummy = new ComCookieDummy(); if (cfg.addBpxBattDummy) { @@ -74,7 +75,8 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio } auto* imtqAssy = new ImtqAssembly(objects::IMTQ_ASSY); imtqAssy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); - auto* imtqDummy = new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + auto* imtqDummy = + new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, enableHkSets); imtqDummy->enableThermalModule(ThermalStateCfg()); imtqDummy->connectModeTreeParent(*imtqAssy); if (cfg.addOnlyAcuDummy) { diff --git a/dummies/helperFactory.h b/dummies/helperFactory.h index e3809404..467cb172 100644 --- a/dummies/helperFactory.h +++ b/dummies/helperFactory.h @@ -22,6 +22,6 @@ struct DummyCfg { bool addCamSwitcherDummy = true; }; -void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch, GpioIF* gpioIF); +void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch, GpioIF* gpioIF, bool enableHkSets); } // namespace dummy From 758f2b9d7ab312196a0dda273c3be6ced0edf008 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 May 2023 11:15:58 +0200 Subject: [PATCH 080/172] add ACU HK sets --- dummies/AcuDummy.cpp | 49 +++++++++++++++++++++++++++++++++++++-- dummies/AcuDummy.h | 8 ++++++- dummies/helperFactory.cpp | 4 ++-- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/dummies/AcuDummy.cpp b/dummies/AcuDummy.cpp index 7c18f6bf..c9844eb1 100644 --- a/dummies/AcuDummy.cpp +++ b/dummies/AcuDummy.cpp @@ -2,8 +2,11 @@ #include -AcuDummy::AcuDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) - : DeviceHandlerBase(objectId, comif, comCookie) {} +AcuDummy::AcuDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, bool enableHkSets) + : DeviceHandlerBase(objectId, comif, comCookie), + coreHk(this), + auxHk(this), + enableHkSets(enableHkSets) {} AcuDummy::~AcuDummy() {} @@ -37,7 +40,49 @@ uint32_t AcuDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return ReturnValue_t AcuDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + using namespace ACU; + localDataPoolMap.emplace(pool::ACU_CURRENT_IN_CHANNELS, new PoolEntry(6)); + localDataPoolMap.emplace(pool::ACU_VOLTAGE_IN_CHANNELS, new PoolEntry(6)); + + localDataPoolMap.emplace(pool::ACU_VCC, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_VBAT, new PoolEntry({0})); + localDataPoolMap.emplace(ACU::pool::ACU_TEMPERATURES, new PoolEntry({10.0, 10.0, 10.0}, true)); + + localDataPoolMap.emplace(pool::ACU_MPPT_MODE, new PoolEntry({0})); + + localDataPoolMap.emplace(pool::ACU_VBOOST_IN_CHANNELS, new PoolEntry(6)); + localDataPoolMap.emplace(pool::ACU_POWER_IN_CHANNELS, new PoolEntry(6)); + + localDataPoolMap.emplace(pool::ACU_DAC_ENABLES, new PoolEntry(3)); + localDataPoolMap.emplace(pool::ACU_DAC_RAW_CHANNELS, new PoolEntry(6)); + + localDataPoolMap.emplace(pool::ACU_BOOTCAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_BOOTCNT, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_UPTIME, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_RESET_CAUSE, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_MPPT_TIME, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_MPPT_PERIOD, new PoolEntry({0})); + + localDataPoolMap.emplace(pool::ACU_DEVICES, new PoolEntry(8)); + localDataPoolMap.emplace(pool::ACU_DEVICES_STATUS, new PoolEntry(8)); + + localDataPoolMap.emplace(pool::ACU_WDT_CNT_GND, new PoolEntry({0})); + localDataPoolMap.emplace(pool::ACU_WDT_GND_LEFT, new PoolEntry({0})); + + poolManager.subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams(coreHk.getSid(), enableHkSets, 30.0)); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(auxHk.getSid(), enableHkSets, 6000.0)); return returnvalue::OK; } + +LocalPoolDataSetBase *AcuDummy::getDataSetHandle(sid_t sid) { + if (sid == coreHk.getSid()) { + return &coreHk; + } else if (sid == auxHk.getSid()) { + return &auxHk; + } + return nullptr; +} diff --git a/dummies/AcuDummy.h b/dummies/AcuDummy.h index d5527222..8d855281 100644 --- a/dummies/AcuDummy.h +++ b/dummies/AcuDummy.h @@ -2,6 +2,7 @@ #define DUMMIES_ACUDUMMY_H_ #include +#include class AcuDummy : public DeviceHandlerBase { public: @@ -11,10 +12,14 @@ class AcuDummy : public DeviceHandlerBase { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - AcuDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + AcuDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, bool enableHkSets); virtual ~AcuDummy(); protected: + ACU::CoreHk coreHk; + ACU::AuxHk auxHk; + bool enableHkSets; + void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; @@ -28,6 +33,7 @@ class AcuDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; }; #endif /* DUMMIES_ACUDUMMY_H_ */ diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index 90a50160..16de01f0 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -80,9 +80,9 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio imtqDummy->enableThermalModule(ThermalStateCfg()); imtqDummy->connectModeTreeParent(*imtqAssy); if (cfg.addOnlyAcuDummy) { - new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, enableHkSets); } else if (cfg.addPowerDummies) { - new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, enableHkSets); new PduDummy(objects::PDU1_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); new PduDummy(objects::PDU2_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); new P60DockDummy(objects::P60DOCK_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); From 9e0989915c6087be44247352933db4106db2a44b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 May 2023 11:16:35 +0200 Subject: [PATCH 081/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cda8e93b..bae37800 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ will consitute of a breaking change warranting a new major release: - Add the remaining system modes. - PLOC MPSoC flash read command working. - BPX battery handler is added for EM by default. +- ACU dummy HK sets. ## Fixed From b899bad0a81c30de37951c3b2ed85011ea756f4a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 May 2023 11:17:00 +0200 Subject: [PATCH 082/172] IMTQ HK sets --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cda8e93b..56943595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ will consitute of a breaking change warranting a new major release: - Add the remaining system modes. - PLOC MPSoC flash read command working. - BPX battery handler is added for EM by default. +- IMTQ HK sets ## Fixed From 31e24e297ff6baf5d4683bbf67951938fcf6f470 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 May 2023 11:53:07 +0200 Subject: [PATCH 083/172] fix host SW --- bsp_hosted/ObjectFactory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bsp_hosted/ObjectFactory.cpp b/bsp_hosted/ObjectFactory.cpp index 018d0e56..dd88d552 100644 --- a/bsp_hosted/ObjectFactory.cpp +++ b/bsp_hosted/ObjectFactory.cpp @@ -62,6 +62,10 @@ void ObjectFactory::produce(void* args) { StorageManagerIF* tmStore; StorageManagerIF* ipcStore; PersistentTmStores persistentStores; + bool enableHkSets = false; +#if OBSW_ENABLE_PERIODIC_HK == 1 + enableHkSets = true; +#endif auto sdcMan = new DummySdCardManager("/tmp"); ObjectFactory::produceGenericObjects(nullptr, &pusFunnel, &cfdpFunnel, *sdcMan, &ipcStore, &tmStore, persistentStores, 120); @@ -101,7 +105,7 @@ void ObjectFactory::produce(void* args) { #endif dummy::DummyCfg cfg; - dummy::createDummies(cfg, *dummySwitcher, dummyGpioIF); + dummy::createDummies(cfg, *dummySwitcher, dummyGpioIF, enableHkSets); HeaterHandler* heaterHandler = nullptr; // new ThermalController(objects::THERMAL_CONTROLLER); From 276501c504d50e7822dbb44d2163eff957140ad5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 May 2023 08:43:52 +0200 Subject: [PATCH 084/172] another tweak for TM stores --- mission/com/TmStoreTaskBase.cpp | 23 ++++++++++------------- mission/com/VirtualChannel.cpp | 4 +--- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/mission/com/TmStoreTaskBase.cpp b/mission/com/TmStoreTaskBase.cpp index 2158cf2a..0470dc04 100644 --- a/mission/com/TmStoreTaskBase.cpp +++ b/mission/com/TmStoreTaskBase.cpp @@ -131,25 +131,22 @@ ReturnValue_t TmStoreTaskBase::performDump(PersistentTmStoreWithTmQueue& store, dumpContext.ptmeBusyCounter = 0; tmSinkBusyCd.resetTimer(); ReturnValue_t result = store.getNextDumpPacket(tmReader, fileHasSwapped); - if (result != returnvalue::OK) { - sif::error << "PersistentTmStore: Getting next dump packet failed" << std::endl; - } else if (fileHasSwapped and result == PersistentTmStore::DUMP_DONE) { + if (fileHasSwapped and result == PersistentTmStore::DUMP_DONE) { // This can happen if a file is corrupted and the next file swap completes the dump. dumpDoneHandler(); return returnvalue::OK; + } else if (result != returnvalue::OK) { + sif::error << "PersistentTmStore: Getting next dump packet failed" << std::endl; + return result; } dumpedLen = tmReader.getFullPacketLen(); - // Only write to VC if mode is on, but always confirm the dump. - // If the mode is OFF, it is assumed the PTME is not usable and is not allowed to be written - // (e.g. to confirm a reset or the transmitter is off anyway). - if (mode == MODE_ON) { - result = channel.write(tmReader.getFullData(), dumpedLen); - if (result == DirectTmSinkIF::IS_BUSY) { - sif::warning << "PersistentTmStore: Unexpected VC channel busy" << std::endl; - } else if (result != returnvalue::OK) { - sif::warning << "PersistentTmStore: Unexpected VC channel write failure" << std::endl; - } + result = channel.write(tmReader.getFullData(), dumpedLen); + if (result == DirectTmSinkIF::IS_BUSY) { + sif::warning << "PersistentTmStore: Unexpected VC channel busy" << std::endl; + } else if (result != returnvalue::OK) { + sif::warning << "PersistentTmStore: Unexpected VC channel write failure" << std::endl; } + result = store.confirmDump(tmReader, fileHasSwapped); if ((result == PersistentTmStore::DUMP_DONE or result == returnvalue::OK)) { dumpPerformed = true; diff --git a/mission/com/VirtualChannel.cpp b/mission/com/VirtualChannel.cpp index ea5527a8..ff3749a9 100644 --- a/mission/com/VirtualChannel.cpp +++ b/mission/com/VirtualChannel.cpp @@ -18,9 +18,7 @@ uint8_t VirtualChannel::getVcid() const { return vcId; } const char* VirtualChannel::getName() const { return vcName.c_str(); } -bool VirtualChannel::isBusy() const { - return ptme.isBusy(vcId); -} +bool VirtualChannel::isBusy() const { return ptme.isBusy(vcId); } void VirtualChannel::cancelTransfer() { ptme.cancelTransfer(vcId); } From 8d041c67538a1f1dc85f16591a71d2e88920a04c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 May 2023 08:45:20 +0200 Subject: [PATCH 085/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 376a7f64..7e7ba753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ will consitute of a breaking change warranting a new major release: - Transmitter state is not taken into account anymore for writing into the PTME. The PTME should be perfectly capable of generating a valid CADU, even when the transmitter is not ON for any reason. +- OFF mode is ignores in TM store for determining whether a store will be written. The modes will + only be used to cancel a transfer. ## Added From e1aff4c641ac2ee7df2475d3aba6a5ea963fab36 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 25 May 2023 08:48:03 +0200 Subject: [PATCH 086/172] another small logic fix --- CHANGELOG.md | 1 + mission/tmtc/PersistentTmStore.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e7ba753..341f1a26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ will consitute of a breaking change warranting a new major release: - HK TM store: The HK store dump success event was triggered for cancelled HK dumps. - When a PUS parsing error occured while parsing a TM store file, the dump completion procedure was always executed. +- Some smaller logic fixes in the TM store base class # [v2.0.5] 2023-05-11 diff --git a/mission/tmtc/PersistentTmStore.cpp b/mission/tmtc/PersistentTmStore.cpp index 7c3738fc..8174f8a0 100644 --- a/mission/tmtc/PersistentTmStore.cpp +++ b/mission/tmtc/PersistentTmStore.cpp @@ -256,6 +256,7 @@ ReturnValue_t PersistentTmStore::getNextDumpPacket(PusTmReader& reader, bool& fi if (state == State::IDLE or dumpParams.pendingPacketDump) { return returnvalue::FAILED; } + fileHasSwapped = false; reader.setReadOnlyData(fileBuf.data() + dumpParams.currentSize, fileBuf.size() - dumpParams.currentSize); // CRC check to fully ensure this is a valid TM @@ -270,7 +271,6 @@ ReturnValue_t PersistentTmStore::getNextDumpPacket(PusTmReader& reader, bool& fi fileHasSwapped = true; return loadNextDumpFile(); } - fileHasSwapped = false; dumpParams.pendingPacketDump = true; return returnvalue::OK; } From db79e34d3bcc3c72fad0dbf2352d530d15702b69 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 25 May 2023 11:20:28 +0200 Subject: [PATCH 087/172] added switcher for IMTQ dummy --- dummies/ImtqDummy.cpp | 14 ++++++++++++-- dummies/ImtqDummy.h | 6 +++++- dummies/helperFactory.cpp | 5 +++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dummies/ImtqDummy.cpp b/dummies/ImtqDummy.cpp index 8f8d1513..0c8f9076 100644 --- a/dummies/ImtqDummy.cpp +++ b/dummies/ImtqDummy.cpp @@ -3,11 +3,12 @@ #include ImtqDummy::ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, - bool enableHkSets) + power::Switch_t pwrSwitcher, bool enableHkSets) : DeviceHandlerBase(objectId, comif, comCookie), setNoTorque(this), setWithTorque(this), - enableHkSets(enableHkSets) {} + enableHkSets(enableHkSets), + switcher(pwrSwitcher) {} ImtqDummy::~ImtqDummy() = default; @@ -15,6 +16,15 @@ void ImtqDummy::doStartUp() { setMode(MODE_NORMAL); } void ImtqDummy::doShutDown() { setMode(_MODE_POWER_DOWN); } +ReturnValue_t ImtqDummy::getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) { + if (switcher != power::NO_SWITCH) { + *numberOfSwitches = 1; + *switches = &switcher; + return returnvalue::OK; + } + return DeviceHandlerBase::NO_SWITCH; +} + ReturnValue_t ImtqDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { return NOTHING_TO_SEND; } ReturnValue_t ImtqDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { diff --git a/dummies/ImtqDummy.h b/dummies/ImtqDummy.h index 5a1de175..990df6e0 100644 --- a/dummies/ImtqDummy.h +++ b/dummies/ImtqDummy.h @@ -13,10 +13,12 @@ class ImtqDummy : public DeviceHandlerBase { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, bool enableHkSets); + ImtqDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie, + power::Switch_t pwrSwitcher, bool enableHkSets); ~ImtqDummy() override; protected: + ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; imtq::HkDatasetNoTorque setNoTorque; imtq::HkDatasetWithTorque setWithTorque; bool enableHkSets; @@ -38,6 +40,8 @@ class ImtqDummy : public DeviceHandlerBase { PoolEntry mtmRawWithTorque = PoolEntry(3); PoolEntry actStatusWithTorque = PoolEntry(1); + power::Switch_t switcher = power::NO_SWITCH; + void doStartUp() override; void doShutDown() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index 16de01f0..157d11d3 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -75,9 +75,10 @@ void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpio } auto* imtqAssy = new ImtqAssembly(objects::IMTQ_ASSY); imtqAssy->connectModeTreeParent(satsystem::acs::ACS_SUBSYSTEM); - auto* imtqDummy = - new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, enableHkSets); + auto* imtqDummy = new ImtqDummy(objects::IMTQ_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, + power::Switches::PDU1_CH3_MGT_5V, enableHkSets); imtqDummy->enableThermalModule(ThermalStateCfg()); + imtqDummy->setPowerSwitcher(&pwrSwitcher); imtqDummy->connectModeTreeParent(*imtqAssy); if (cfg.addOnlyAcuDummy) { new AcuDummy(objects::ACU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy, enableHkSets); From a6787538f2baaa6481ad9cbb1596b014952a16f6 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 25 May 2023 11:21:28 +0200 Subject: [PATCH 088/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 341f1a26..39f6a0a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ will consitute of a breaking change warranting a new major release: - BPX battery handler is added for EM by default. - ACU dummy HK sets - IMTQ HK sets +- IMTQ dummy now handles power switch ## Fixed From 5afe22bc92042144b1bb54a91066f5a0a05f70b0 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 25 May 2023 15:48:28 +0200 Subject: [PATCH 089/172] heater mode fix --- mission/tcs/HeaterHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mission/tcs/HeaterHandler.cpp b/mission/tcs/HeaterHandler.cpp index 630dc92c..f422f382 100644 --- a/mission/tcs/HeaterHandler.cpp +++ b/mission/tcs/HeaterHandler.cpp @@ -268,6 +268,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switch heaterIdx) { triggerEvent(GPIO_PULL_HIGH_FAILED, result); } else { triggerEvent(HEATER_WENT_ON, heaterIdx, 0); + EventManagerIF::triggerEvent(helper.heaters[heaterIdx].first->getObjectId(), MODE_INFO, + MODE_ON, MODE_OFF); { MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); heater.switchState = ON; @@ -324,6 +326,8 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switch heaterIdx) { heater.switchState = OFF; } triggerEvent(HEATER_WENT_OFF, heaterIdx, 0); + EventManagerIF::triggerEvent(helper.heaters[heaterIdx].first->getObjectId(), MODE_INFO, + MODE_OFF, MODE_ON); // When all switches are off, also main line switch will be turned off if (allSwitchesOff()) { mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); From de18ebfbe0798dbcf037d092a6afe58ac82e698b Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 26 May 2023 09:57:03 +0200 Subject: [PATCH 090/172] fixed error angle being calculated but not returned --- mission/controller/acs/Guidance.cpp | 4 ++-- mission/controller/acs/Guidance.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mission/controller/acs/Guidance.cpp b/mission/controller/acs/Guidance.cpp index 79c6b416..7c8fc2a1 100644 --- a/mission/controller/acs/Guidance.cpp +++ b/mission/controller/acs/Guidance.cpp @@ -412,7 +412,7 @@ void Guidance::targetQuatPtgNadirThreeAxes(timeval now, double posSatE[3], doubl void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], double targetQuat[4], double targetSatRotRate[3], double refQuat[4], double refSatRotRate[3], - double errorQuat[4], double errorSatRotRate[3], double errorAngle) { + double errorQuat[4], double errorSatRotRate[3], double &errorAngle) { // First calculate error quaternion between current and target orientation QuaternionOperations::multiply(currentQuat, targetQuat, errorQuat); // Last calculate add rotation from reference quaternion @@ -443,7 +443,7 @@ void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], do void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], double targetQuat[4], double targetSatRotRate[3], double errorQuat[4], - double errorSatRotRate[3], double errorAngle) { + double errorSatRotRate[3], double &errorAngle) { // First calculate error quaternion between current and target orientation QuaternionOperations::multiply(currentQuat, targetQuat, errorQuat); // Keep scalar part of quaternion positive diff --git a/mission/controller/acs/Guidance.h b/mission/controller/acs/Guidance.h index a52c476a..39e77456 100644 --- a/mission/controller/acs/Guidance.h +++ b/mission/controller/acs/Guidance.h @@ -37,15 +37,15 @@ class Guidance { double targetQuat[4], double refSatRate[3]); // @note: Calculates the error quaternion between the current orientation and the target - // quaternion, considering a reference quaternion. Additionally the difference between the actual + // quaternion, considering a reference quaternion. Additionally the difference between the actual // and a desired satellite rotational rate is calculated, again considering a reference rotational // rate. Lastly gives back the error angle of the error quaternion. void comparePtg(double currentQuat[4], double currentSatRotRate[3], double targetQuat[4], double targetSatRotRate[3], double refQuat[4], double refSatRotRate[3], - double errorQuat[4], double errorSatRotRate[3], double errorAngle); + double errorQuat[4], double errorSatRotRate[3], double &errorAngle); void comparePtg(double currentQuat[4], double currentSatRotRate[3], double targetQuat[4], double targetSatRotRate[3], double errorQuat[4], double errorSatRotRate[3], - double errorAngle); + double &errorAngle); void targetRotationRate(int8_t timeElapsedMax, timeval now, double quatInertialTarget[4], double *targetSatRotRate); From 335394b8639814edee4b107e087482ac46cd9cd9 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 26 May 2023 13:51:24 +0200 Subject: [PATCH 091/172] fixed use of c abs which will truncate the value --- mission/controller/acs/ActuatorCmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index d2fe2d65..a8fab6a4 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -61,7 +61,7 @@ void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentAct // Scaling along largest element if dipol exceeds maximum uint8_t maxIdx = 0; VectorOperations::maxAbsValue(dipolMomentActuatorDouble, 3, &maxIdx); - double maxAbsValue = abs(dipolMomentActuatorDouble[maxIdx]); + double maxAbsValue = std::abs(dipolMomentActuatorDouble[maxIdx]); if (maxAbsValue > maxDipol) { double scalingFactor = maxDipol / maxAbsValue; VectorOperations::mulScalar(dipolMomentActuatorDouble, scalingFactor, From a7c6cd017d80b88bfe64418d6f00b6634dc5c264 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 26 May 2023 13:53:46 +0200 Subject: [PATCH 092/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39f6a0a8..1dfeed76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,8 @@ will consitute of a breaking change warranting a new major release: - When a PUS parsing error occured while parsing a TM store file, the dump completion procedure was always executed. - Some smaller logic fixes in the TM store base class +- Fixed usage of C `abs` instead of C++ `std::abs`, which results in MTQ commands not being + scaled correctly between 1Am² and 0.2Am². # [v2.0.5] 2023-05-11 From 9c78362ac534b8f665c72b97f4a64a29b5368553 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 27 May 2023 17:00:41 +0200 Subject: [PATCH 093/172] use read write permissions for uio --- linux/ipcore/PapbVcInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 7a1a89e4..bf1f48bb 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -16,7 +16,7 @@ PapbVcInterface::~PapbVcInterface() {} ReturnValue_t PapbVcInterface::initialize() { UioMapper uioMapper(uioFile, mapNum); ReturnValue_t result = uioMapper.getMappedAdress(const_cast(&vcBaseReg), - UioMapper::Permissions::WRITE_ONLY); + UioMapper::Permissions::READ_WRITE); if (result != returnvalue::OK) { return result; } From 71eca867ea630fad8bcb4c5feb4d197af0e3c3a7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 27 May 2023 17:03:33 +0200 Subject: [PATCH 094/172] i think the rad sesnor messing everything up --- CMakeLists.txt | 2 +- bsp_q7s/em/emObjectFactory.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5ecf173..d47be117 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ set(OBSW_ADD_THERMAL_TEMP_INSERTER ${OBSW_Q7S_EM} CACHE STRING "Add thermal sensor temperature inserter") set(OBSW_ADD_ACS_BOARD - 1 + ${INIT_VAL} CACHE STRING "Add ACS board module") set(OBSW_ADD_GPS_CTRL ${INIT_VAL} diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 59660b86..72a58987 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -98,7 +98,7 @@ void ObjectFactory::produce(void* args) { // and will cause xsc_boot_copy commands to always boot to 0 0 // createRadSensorComponent(gpioComIF); // Still initialize chip select to avoid SPI bus issues. - createRadSensorChipSelect(gpioComIF); + // createRadSensorChipSelect(gpioComIF); #if OBSW_ADD_ACS_BOARD == 1 createAcsBoardComponents(*spiMainComIF, gpioComIF, uartComIF, *pwrSwitcher, true, From ada77ed53bb7f070fa3f2c71cd8443c6bc0aad8a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 09:22:59 +0200 Subject: [PATCH 095/172] ACS board still required --- bsp_q7s/em/emObjectFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 72a58987..5b2935b7 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -97,10 +97,10 @@ void ObjectFactory::produce(void* args) { // TODO: Careful! Switching this on somehow messes with the communication with the ProASIC // and will cause xsc_boot_copy commands to always boot to 0 0 // createRadSensorComponent(gpioComIF); - // Still initialize chip select to avoid SPI bus issues. - // createRadSensorChipSelect(gpioComIF); #if OBSW_ADD_ACS_BOARD == 1 + // Still initialize chip select to avoid SPI bus issues. + createRadSensorChipSelect(gpioComIF); createAcsBoardComponents(*spiMainComIF, gpioComIF, uartComIF, *pwrSwitcher, true, adis1650x::Type::ADIS16507); #else From c5640c9fca3f62bef8afe1dba93dbc1bf90bf221 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 15:14:07 +0200 Subject: [PATCH 096/172] prevent SPAM --- mission/controller/ThermalController.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 7133dd88..4c475e35 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -1631,13 +1631,18 @@ bool ThermalController::selectAndReadSensorTemp(HeaterContext& htrCtx) { bool ThermalController::chooseHeater(heater::Switch& switchNr, heater::Switch redSwitchNr) { bool heaterAvailable = true; - if (heaterHandler.getHealth(switchNr) != HasHealthIF::HEALTHY) { - if (heaterHandler.getHealth(redSwitchNr) == HasHealthIF::HEALTHY) { + HasHealthIF::HealthState mainHealth = heaterHandler.getHealth(switchNr); + HasHealthIF::HealthState redHealth = heaterHandler.getHealth(redSwitchNr); + if (mainHealth != HasHealthIF::HEALTHY) { + if (redHealth == HasHealthIF::HEALTHY) { switchNr = redSwitchNr; redSwitchNrInUse = true; } else { heaterAvailable = false; - triggerEvent(tcsCtrl::NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + // Special case: Ground might command/do something with the heaters, so prevent spam. + if (not(mainHealth == EXTERNAL_CONTROL and redHealth == EXTERNAL_CONTROL)) { + triggerEvent(tcsCtrl::NO_HEALTHY_HEATER_AVAILABLE, switchNr, redSwitchNr); + } } } else { redSwitchNrInUse = false; From b135e2f6a155fd9accd1165d773294133412bf04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 15:14:47 +0200 Subject: [PATCH 097/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dfeed76..a9b4f3ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,7 @@ will consitute of a breaking change warranting a new major release: - Some smaller logic fixes in the TM store base class - Fixed usage of C `abs` instead of C++ `std::abs`, which results in MTQ commands not being scaled correctly between 1Am² and 0.2Am². +- Prevent spam of TCS controller heater unavailability event if all heaters are in external control. # [v2.0.5] 2023-05-11 From 7811a4cc6ba36840977c7166dec79f9d43c2e38b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 15:17:11 +0200 Subject: [PATCH 098/172] small fix for mode event heater --- mission/tcs/HeaterHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/tcs/HeaterHandler.cpp b/mission/tcs/HeaterHandler.cpp index f422f382..de4b600d 100644 --- a/mission/tcs/HeaterHandler.cpp +++ b/mission/tcs/HeaterHandler.cpp @@ -269,7 +269,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switch heaterIdx) { } else { triggerEvent(HEATER_WENT_ON, heaterIdx, 0); EventManagerIF::triggerEvent(helper.heaters[heaterIdx].first->getObjectId(), MODE_INFO, - MODE_ON, MODE_OFF); + MODE_ON, 0); { MutexGuard mg(handlerLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); heater.switchState = ON; @@ -327,7 +327,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switch heaterIdx) { } triggerEvent(HEATER_WENT_OFF, heaterIdx, 0); EventManagerIF::triggerEvent(helper.heaters[heaterIdx].first->getObjectId(), MODE_INFO, - MODE_OFF, MODE_ON); + MODE_OFF, 0); // When all switches are off, also main line switch will be turned off if (allSwitchesOff()) { mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); From ebf5609680f6010976f541c0efad9eb9559173bf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 16:45:09 +0200 Subject: [PATCH 099/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dfeed76..c48e327f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,6 +86,8 @@ will consitute of a breaking change warranting a new major release: - Some smaller logic fixes in the TM store base class - Fixed usage of C `abs` instead of C++ `std::abs`, which results in MTQ commands not being scaled correctly between 1Am² and 0.2Am². +- TCS Heater Handler: Always trigger mode event if a heater goes `OFF` or `ON`. This event might + soon replace the `HEATER_WENT_ON` and `HEATER_WENT_OFF` events. # [v2.0.5] 2023-05-11 From 0aa617d4401ee3641b8e167db963366feb69aa04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 16:54:56 +0200 Subject: [PATCH 100/172] switch info fix --- CHANGELOG.md | 2 ++ mission/controller/ThermalController.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a12c68bb..990ed751 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,8 @@ will consitute of a breaking change warranting a new major release: - TCS Heater Handler: Always trigger mode event if a heater goes `OFF` or `ON`. This event might soon replace the `HEATER_WENT_ON` and `HEATER_WENT_OFF` events. - Prevent spam of TCS controller heater unavailability event if all heaters are in external control. +- TCS heater switch info set contained invalid values because of a faulty `memcpy` in the TCS + controller. There is not crash risk but the heater states were invalid. # [v2.0.5] 2023-05-11 diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 4c475e35..6205ce44 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -175,7 +175,7 @@ void ThermalController::performControlOperation() { heaterHandler.getAllSwitchStates(heaterSwitchStateArray); { PoolReadGuard pg(&heaterInfo); - std::memcpy(heaterInfo.heaterSwitchState.value, heaterStates.data(), 8); + std::memcpy(heaterInfo.heaterSwitchState.value, heaterSwitchStateArray.data(), 8); { PoolReadGuard pg2(¤tVecPdu2); if (pg.getReadResult() == returnvalue::OK and pg2.getReadResult() == returnvalue::OK) { From 9921522ce0c1ec36e2faea7e9584cd7c7390b61b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 19:06:59 +0200 Subject: [PATCH 101/172] working, remove some old unrequired code --- mission/com/PersistentLogTmStoreTask.cpp | 6 ------ mission/com/PersistentSingleTmStoreTask.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/mission/com/PersistentLogTmStoreTask.cpp b/mission/com/PersistentLogTmStoreTask.cpp index 0d47e50f..28545457 100644 --- a/mission/com/PersistentLogTmStoreTask.cpp +++ b/mission/com/PersistentLogTmStoreTask.cpp @@ -42,13 +42,7 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) { if (not someonesBusy) { TaskFactory::delayTask(100); } else if (vcBusyDuringDump) { - // TODO: Might not be necessary - sif::debug << "VC busy, delaying" << std::endl; TaskFactory::delayTask(10); - } else { - // TODO: Would be best to remove this, but not delaying here can lead to evil issues. - // Polling the PAPB of the PTME core too often leads to scheuduling issues. - // TaskFactory::delayTask(2); } } } diff --git a/mission/com/PersistentSingleTmStoreTask.cpp b/mission/com/PersistentSingleTmStoreTask.cpp index 2afc8e31..d6f43289 100644 --- a/mission/com/PersistentSingleTmStoreTask.cpp +++ b/mission/com/PersistentSingleTmStoreTask.cpp @@ -24,13 +24,7 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) { if (not busy) { TaskFactory::delayTask(100); } else if (dumpContext.vcBusyDuringDump) { - sif::debug << "VC busy, delaying" << std::endl; - // TODO: Might not be necessary TaskFactory::delayTask(10); - } else { - // TODO: Would be best to remove this, but not delaying here can lead to evil issues. - // Polling the PAPB of the PTME core too often leads to scheuduling issues. - // TaskFactory::delayTask(2); } } } From ddcdc38310b1ea0a2f247cb3472f8a29bf0ec0bc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 May 2023 19:22:23 +0200 Subject: [PATCH 102/172] try to get rid of the nanosleep --- linux/ipcore/PapbVcInterface.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index bf1f48bb..97eb9954 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -65,12 +65,6 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { // idx += 4; // } for (size_t idx = 0; idx < size; idx++) { - // This delay is super-important, DO NOT REMOVE! - // Polling the GPIO or the config register too often messes up the scheduler. - // TODO: Maybe this should not be done like this. It would be better if there was a custom - // FPGA module which can accept packets and then takes care of dumping that packet into - // the PTME. DMA would be an ideal solution for this. - nanosleep(&BETWEEN_POLL_DELAY, &remDelay); if (pollInterfaceReadiness(2, false) == returnvalue::OK) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(data[idx]); } else { @@ -78,7 +72,6 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { return returnvalue::FAILED; } } - nanosleep(&BETWEEN_POLL_DELAY, &remDelay); if (pollInterfaceReadiness(2, false) == returnvalue::OK) { completePacketTransfer(); } else { From 23625b24963dc2a3d7fd85b47bfbcb6568f7e948 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 09:53:13 +0200 Subject: [PATCH 103/172] move 2 pool variables --- mission/power/gsDefs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mission/power/gsDefs.h b/mission/power/gsDefs.h index d42cabd2..00bdf589 100644 --- a/mission/power/gsDefs.h +++ b/mission/power/gsDefs.h @@ -404,6 +404,11 @@ class PduCoreHk : public StaticLocalDataSet<9> { /** Battery mode: 1 = Critical, 2 = Safe, 3 = Normal, 4 = Full */ lp_var_t battMode = lp_var_t(sid.objectId, pool::PDU_BATT_MODE, this); lp_var_t temperature = lp_var_t(sid.objectId, pool::PDU_TEMPERATURE, this); + + /** Measured VCC */ + lp_var_t vcc = lp_var_t(sid.objectId, pool::PDU_VCC, this); + /** Measured VBAT */ + lp_var_t vbat = lp_var_t(sid.objectId, pool::PDU_VBAT, this); }; class PduConfig : public StaticLocalDataSet<32> { @@ -451,11 +456,6 @@ class PduAuxHk : public StaticLocalDataSet<36> { PduAuxHk(object_id_t objectId, uint32_t setId) : StaticLocalDataSet(sid_t(objectId, setId)) {} - /** Measured VCC */ - lp_var_t vcc = lp_var_t(sid.objectId, pool::PDU_VCC, this); - /** Measured VBAT */ - lp_var_t vbat = lp_var_t(sid.objectId, pool::PDU_VBAT, this); - /** Output converter enable status */ lp_vec_t converterEnable = lp_vec_t(sid.objectId, pool::PDU_CONV_EN, this); From f4523c8396e1d3684079e3d5b26c9afb948cba12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 10:39:56 +0200 Subject: [PATCH 104/172] that should fix some issues --- mission/power/GomspaceDeviceHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/power/GomspaceDeviceHandler.cpp b/mission/power/GomspaceDeviceHandler.cpp index 89fca8ee..c20ac4e9 100644 --- a/mission/power/GomspaceDeviceHandler.cpp +++ b/mission/power/GomspaceDeviceHandler.cpp @@ -595,8 +595,8 @@ ReturnValue_t GomspaceDeviceHandler::parsePduHkTable(PDU::PduCoreHk& coreHk, PDU for (uint8_t idx = 0; idx < PDU::CHANNELS_LEN; idx++) { coreHk.voltages[idx] = as(packet + 0x12 + (idx * 2)); } - auxHk.vcc.value = as(packet + 0x24); - auxHk.vbat.value = as(packet + 0x26); + coreHk.vcc.value = as(packet + 0x24); + coreHk.vbat.value = as(packet + 0x26); coreHk.temperature = as(packet + 0x28) * 0.1; for (uint8_t idx = 0; idx < 3; idx++) { From 170cb4d99cb970734af34d338be467157cde8f94 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 10:45:40 +0200 Subject: [PATCH 105/172] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 990ed751..7890df35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ will consitute of a breaking change warranting a new major release: # [v2.2.0] to be released -# [v2.1.0] to be released +# [v3.0.0] to be released ## Changed From ec8e8533d67d966208c8cc5d59ab53a5dc4210b6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 11:49:18 +0200 Subject: [PATCH 106/172] bump version --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d47be117..eaa2d340 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,9 @@ # ############################################################################## cmake_minimum_required(VERSION 3.13) -set(OBSW_VERSION_MAJOR 2) +set(OBSW_VERSION_MAJOR 3) set(OBSW_VERSION_MINOR 0) -set(OBSW_VERSION_REVISION 5) +set(OBSW_VERSION_REVISION 0) # set(CMAKE_VERBOSE TRUE) From 0b06bc4c8b286046190e055876644fe6aa384693 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 11:52:45 +0200 Subject: [PATCH 107/172] bump major version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eaa2d340..26bcbd80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ # ############################################################################## cmake_minimum_required(VERSION 3.13) -set(OBSW_VERSION_MAJOR 3) +set(OBSW_VERSION_MAJOR 4) set(OBSW_VERSION_MINOR 0) set(OBSW_VERSION_REVISION 0) From 8113a71c79b94ae7b72ff6d5cc4d26715d7ce497 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 14:15:54 +0200 Subject: [PATCH 108/172] PAPB VC simplification --- linux/ipcore/PapbVcInterface.cpp | 93 ++++++++++++++++---------------- linux/ipcore/PapbVcInterface.h | 3 +- 2 files changed, 47 insertions(+), 49 deletions(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 97eb9954..1920e932 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -28,7 +28,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { if (size < 4) { return returnvalue::FAILED; } - if (pollInterfaceReadiness(0, true) == returnvalue::OK) { + if (not pollReadyForPacket()) { startPacketTransfer(ByteWidthCfg::ONE); } else { return DirectTmSinkIF::IS_BUSY; @@ -65,19 +65,19 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { // idx += 4; // } for (size_t idx = 0; idx < size; idx++) { - if (pollInterfaceReadiness(2, false) == returnvalue::OK) { - *(vcBaseReg + DATA_REG_OFFSET) = static_cast(data[idx]); - } else { - abortPacketTransfer(); - return returnvalue::FAILED; - } - } - if (pollInterfaceReadiness(2, false) == returnvalue::OK) { - completePacketTransfer(); - } else { - abortPacketTransfer(); - return returnvalue::FAILED; + // if (pollInterfaceReadiness(2, false) == returnvalue::OK) { + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(data[idx]); + //} else { + // abortPacketTransfer(); + // return returnvalue::FAILED; + //} } + // if (pollInterfaceReadiness(2, false) == returnvalue::OK) { + completePacketTransfer(); + //} else { + // abortPacketTransfer(); + // return returnvalue::FAILED; + //} return returnvalue::OK; } @@ -87,40 +87,39 @@ void PapbVcInterface::startPacketTransfer(ByteWidthCfg initWidth) { void PapbVcInterface::completePacketTransfer() { *vcBaseReg = CONFIG_END; } -ReturnValue_t PapbVcInterface::pollInterfaceReadiness(uint32_t maxPollRetries, - bool checkReadyForPacketState) const { - uint32_t busyIdx = 0; - nextDelay.tv_nsec = FIRST_DELAY_PAPB_POLLING_NS; +bool PapbVcInterface::pollReadyForPacket() const { + // uint32_t busyIdx = 0; + // nextDelay.tv_nsec = FIRST_DELAY_PAPB_POLLING_NS; - while (true) { - // Check if PAPB interface is ready to receive data. Use the configuration register for this. - // Bit 5, see PTME ptme_001_01-0-7-r2 Table 31. - uint32_t reg = *vcBaseReg; - bool busy = (reg >> 5) & 0b1; - bool readyForPacket = (reg >> 6) & 0b1; - if (checkReadyForPacketState) { - if (not busy and readyForPacket) { - return returnvalue::OK; - } else if (not busy and not readyForPacket) { - return PAPB_BUSY; - } - } else if (not busy) { - return returnvalue::OK; - } - - busyIdx++; - if (busyIdx >= maxPollRetries) { - return PAPB_BUSY; - } - - // Ignore signal handling here for now. - nanosleep(&nextDelay, &remDelay); - // Adaptive delay. - if (nextDelay.tv_nsec * 2 <= MAX_DELAY_PAPB_POLLING_NS) { - nextDelay.tv_nsec *= 2; - } - } - return returnvalue::OK; + // while (true) { + // Check if PAPB interface is ready to receive data. Use the configuration register for this. + // Bit 5, see PTME ptme_001_01-0-7-r2 Table 31. + uint32_t reg = *vcBaseReg; + // bool busy = (reg >> 5) & 0b1; + return (reg >> 6) & 0b1; + // if (checkReadyForPacketState) { + // if (not busy and readyForPacket) { + // return returnvalue::OK; + // } else if (not busy and not readyForPacket) { + // return PAPB_BUSY; + // } + // } else if (not busy) { + // return returnvalue::OK; + // } + // + // busyIdx++; + // if (busyIdx >= maxPollRetries) { + // return PAPB_BUSY; + // } + // + // // Ignore signal handling here for now. + // nanosleep(&nextDelay, &remDelay); + // // Adaptive delay. + // if (nextDelay.tv_nsec * 2 <= MAX_DELAY_PAPB_POLLING_NS) { + // nextDelay.tv_nsec *= 2; + // } + // } + // return returnvalue::OK; } bool PapbVcInterface::isVcInterfaceBufferEmpty() { @@ -141,7 +140,7 @@ bool PapbVcInterface::isVcInterfaceBufferEmpty() { return false; } -bool PapbVcInterface::isBusy() const { return pollInterfaceReadiness(0, true) == PAPB_BUSY; } +bool PapbVcInterface::isBusy() const { return not pollReadyForPacket(); } void PapbVcInterface::cancelTransfer() { abortPacketTransfer(); } diff --git a/linux/ipcore/PapbVcInterface.h b/linux/ipcore/PapbVcInterface.h index 71dd143b..ba6063b5 100644 --- a/linux/ipcore/PapbVcInterface.h +++ b/linux/ipcore/PapbVcInterface.h @@ -116,8 +116,7 @@ class PapbVcInterface : public VirtualChannelIF { * * @return returnvalue::OK when ready to receive data else PAPB_BUSY. */ - inline ReturnValue_t pollInterfaceReadiness(uint32_t maxPollRetries, - bool checkReadyForPacketState) const; + inline bool pollReadyForPacket() const; /** * @brief This function can be used for debugging to check whether there are packets in From 442b1c94a62781f8f08f0a2fb1ec21426f09c1dc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 15:02:11 +0200 Subject: [PATCH 109/172] small fix --- linux/ipcore/PapbVcInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index 1920e932..fbc13fc5 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -28,7 +28,7 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { if (size < 4) { return returnvalue::FAILED; } - if (not pollReadyForPacket()) { + if (pollReadyForPacket()) { startPacketTransfer(ByteWidthCfg::ONE); } else { return DirectTmSinkIF::IS_BUSY; From 998110dea41ef042681134aec5c49e6de9cfad87 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 16:10:52 +0200 Subject: [PATCH 110/172] back to somethng simple --- linux/ipcore/PapbVcInterface.cpp | 67 -------------------------------- 1 file changed, 67 deletions(-) diff --git a/linux/ipcore/PapbVcInterface.cpp b/linux/ipcore/PapbVcInterface.cpp index fbc13fc5..404f3653 100644 --- a/linux/ipcore/PapbVcInterface.cpp +++ b/linux/ipcore/PapbVcInterface.cpp @@ -33,51 +33,11 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { } else { return DirectTmSinkIF::IS_BUSY; } - // TODO: This should work but does not.. :( - // size_t idx = 0; - // while (idx < size) { - // - // nanosleep(&BETWEEN_POLL_DELAY, &remDelay); - // if ((size - idx) < 4) { - // *vcBaseReg = CONFIG_DATA_INPUT | (size - idx - 1); - // usleep(1); - // } - // if (pollPapbBusySignal(2) == returnvalue::OK) { - // // vcBaseReg + DATA_REG_OFFSET + 3 = static_cast(data + idx); - // // vcBaseReg + DATA_REG_OFFSET + 2 = static_cast(data + idx + 1); - // // vcBaseReg + DATA_REG_OFFSET + 1 = static_cast(data + idx + 2); - // // vcBaseReg + DATA_REG_OFFSET = static_cast(data + idx + 3); - // - // // std::memcpy((vcBaseReg + DATA_REG_OFFSET), data + idx , nextWriteSize); - // *(vcBaseReg + DATA_REG_OFFSET) = *reinterpret_cast(data + idx); - // //uint8_t* byteReg = reinterpret_cast(vcBaseReg + DATA_REG_OFFSET); - // - // //byteReg[0] = data[idx]; - // //byteReg[1] = data[idx]; - // } else { - // abortPacketTransfer(); - // return returnvalue::FAILED; - // } - // // TODO: Change this after the bugfix. Right now, the PAPB ignores the content of the byte - // // width configuration.5 - // // It's okay to increment by a larger amount for the last segment here, loop will be over - // // in any case. - // idx += 4; - // } for (size_t idx = 0; idx < size; idx++) { // if (pollInterfaceReadiness(2, false) == returnvalue::OK) { *(vcBaseReg + DATA_REG_OFFSET) = static_cast(data[idx]); - //} else { - // abortPacketTransfer(); - // return returnvalue::FAILED; - //} } - // if (pollInterfaceReadiness(2, false) == returnvalue::OK) { completePacketTransfer(); - //} else { - // abortPacketTransfer(); - // return returnvalue::FAILED; - //} return returnvalue::OK; } @@ -88,38 +48,11 @@ void PapbVcInterface::startPacketTransfer(ByteWidthCfg initWidth) { void PapbVcInterface::completePacketTransfer() { *vcBaseReg = CONFIG_END; } bool PapbVcInterface::pollReadyForPacket() const { - // uint32_t busyIdx = 0; - // nextDelay.tv_nsec = FIRST_DELAY_PAPB_POLLING_NS; - - // while (true) { // Check if PAPB interface is ready to receive data. Use the configuration register for this. // Bit 5, see PTME ptme_001_01-0-7-r2 Table 31. uint32_t reg = *vcBaseReg; // bool busy = (reg >> 5) & 0b1; return (reg >> 6) & 0b1; - // if (checkReadyForPacketState) { - // if (not busy and readyForPacket) { - // return returnvalue::OK; - // } else if (not busy and not readyForPacket) { - // return PAPB_BUSY; - // } - // } else if (not busy) { - // return returnvalue::OK; - // } - // - // busyIdx++; - // if (busyIdx >= maxPollRetries) { - // return PAPB_BUSY; - // } - // - // // Ignore signal handling here for now. - // nanosleep(&nextDelay, &remDelay); - // // Adaptive delay. - // if (nextDelay.tv_nsec * 2 <= MAX_DELAY_PAPB_POLLING_NS) { - // nextDelay.tv_nsec *= 2; - // } - // } - // return returnvalue::OK; } bool PapbVcInterface::isVcInterfaceBufferEmpty() { From a85b0a4a762c173d942d701e9185237601dd4ed6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 16:31:50 +0200 Subject: [PATCH 111/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffce15e8..87083265 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ TODO: New firmware package version. ## Changed - Removed PTME busy/ready signals. Those were not used anyway because register reads are used now. +- APB bus access busy checking is not done anymore as this is performed by the bus itself now. # [v3.0.0] to be released From f93e299296f6e93ce46f75c1b983fe93cb865e56 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 May 2023 17:29:01 +0200 Subject: [PATCH 112/172] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 6ec0ce20..6182369e 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6ec0ce20fa98877c9f88acb5fe9129254291344b +Subproject commit 6182369e4f40872c5c26e59be25d5fa79339176a From bfa0a0707c5ab33707e58e33870d21511a1cc9e4 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 1 Jun 2023 09:36:34 +0200 Subject: [PATCH 113/172] fixed parameter IDs --- mission/controller/acs/AcsParameters.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 61229c77..5c239133 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -551,10 +551,10 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, case 0xB: parameterWrapper->setVector(nadirModeControllerParameters.quatRef); break; - case 0xB: + case 0xC: parameterWrapper->setVector(nadirModeControllerParameters.refRotRate); break; - case 0xC: + case 0xD: parameterWrapper->set(nadirModeControllerParameters.timeElapsedMax); break; default: From 3750f1ac570c9ecae888515713db75b689cbf4de Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 1 Jun 2023 09:36:50 +0200 Subject: [PATCH 114/172] frmt --- mission/controller/acs/ActuatorCmd.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index a3513bad..9013d6f2 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -57,8 +57,8 @@ void ActuatorCmd::cmdDipoleMtq(const double *inverseAlignment, const double maxD const double *dipoleMoment, int16_t *dipoleMomentActuator) { // convert to actuator frame double dipoleMomentActuatorDouble[3] = {0, 0, 0}; - MatrixOperations::multiply(inverseAlignment, dipoleMoment, dipoleMomentActuatorDouble, 3, 3, - 1); + MatrixOperations::multiply(inverseAlignment, dipoleMoment, dipoleMomentActuatorDouble, 3, + 3, 1); // scaling along largest element if dipole exceeds maximum uint8_t maxIdx = 0; VectorOperations::maxAbsValue(dipoleMomentActuatorDouble, 3, &maxIdx); @@ -69,7 +69,8 @@ void ActuatorCmd::cmdDipoleMtq(const double *inverseAlignment, const double maxD dipoleMomentActuatorDouble, 3); } // scale dipole from 1 Am^2 to 1e^-4 Am^2 - VectorOperations::mulScalar(dipoleMomentActuatorDouble, 1e4, dipoleMomentActuatorDouble, 3); + VectorOperations::mulScalar(dipoleMomentActuatorDouble, 1e4, dipoleMomentActuatorDouble, + 3); for (int i = 0; i < 3; i++) { dipoleMomentActuator[i] = std::round(dipoleMomentActuatorDouble[i]); } From c6664c5cbf684b904da21c5aa8be85c5f865dd5d Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 1 Jun 2023 16:04:51 +0200 Subject: [PATCH 115/172] fixed RW scale for angular momentum calculation --- mission/controller/acs/control/PtgCtrl.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 1ef88ccc..b6f998ec 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -151,6 +151,8 @@ void PtgCtrl::ptgDesaturation(AcsParameters::PointingLawParameters *pointingLawP VectorOperations::mulScalar(acsParameters->rwMatrices.nullspaceVector, pointingLawParameters->nullspaceSpeed, refSpeedRws, 4); VectorOperations::subtract(speedRws, refSpeedRws, speedRws, 4); + // convert speed from 10 RPM to 1 RPM + VectorOperations::mulScalar(speedRws, 1e-1, speedRws, 4); // convert to rad/s VectorOperations::mulScalar(speedRws, RPM_TO_RAD_PER_SEC, speedRws, 4); // calculate angular momentum of each RW From 0fe7b256ecc9729ce1c2e9fb7e5b32615dd9e40d Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 1 Jun 2023 17:11:55 +0200 Subject: [PATCH 116/172] another RW speed scaling fix --- mission/controller/acs/control/PtgCtrl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index b6f998ec..55a3b268 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -111,6 +111,7 @@ void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawPara // calculate resulting angular momentum double rwAngMomentum[4] = {0, 0, 0, 0}, diffRwSpeed[4] = {0, 0, 0, 0}; VectorOperations::subtract(speedRws, rpmOffset, diffRwSpeed, 4); + VectorOperations::mulScalar(diffRwSpeed, 1e-1, diffRwSpeed, 4); VectorOperations::mulScalar(diffRwSpeed, acsParameters->rwHandlingParameters.inertiaWheel, rwAngMomentum, 4); From 4aca7a91e35019415cfd03c704e8212b934da30c Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 09:33:40 +0200 Subject: [PATCH 117/172] fixed more abs --- mission/controller/acs/control/PtgCtrl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index 55a3b268..c978dafc 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -29,10 +29,10 @@ void PtgCtrl::ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters double qErrorLaw[3] = {0, 0, 0}; for (int i = 0; i < 3; i++) { - if (abs(qError[i]) < qErrorMin) { + if (std::abs(qError[i]) < qErrorMin) { qErrorLaw[i] = qErrorMin; } else { - qErrorLaw[i] = abs(qError[i]); + qErrorLaw[i] = std::abs(qError[i]); } } double qErrorLawNorm = VectorOperations::norm(qErrorLaw, 3); @@ -70,7 +70,7 @@ void PtgCtrl::ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters double pErrorSign[3] = {0, 0, 0}; for (int i = 0; i < 3; i++) { - if (abs(pError[i]) > 1) { + if (std::abs(pError[i]) > 1) { pErrorSign[i] = sign(pError[i]); } else { pErrorSign[i] = pError[i]; From f8d9925785e779180db11784600fdc44fbffd429 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 10:43:23 +0200 Subject: [PATCH 118/172] this shouldnt be needed --- mission/controller/acs/Guidance.cpp | 34 +++++++---------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/mission/controller/acs/Guidance.cpp b/mission/controller/acs/Guidance.cpp index 7c8fc2a1..329c6bdc 100644 --- a/mission/controller/acs/Guidance.cpp +++ b/mission/controller/acs/Guidance.cpp @@ -424,21 +424,12 @@ void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], do // Calculate error angle errorAngle = QuaternionOperations::getAngle(errorQuat, true); - // Only give back error satellite rotational rate if orientation has already been aquired - if (errorAngle < 2. / 180. * M_PI) { - // First combine the target and reference satellite rotational rates - double combinedRefSatRotRate[3] = {0, 0, 0}; - VectorOperations::add(targetSatRotRate, refSatRotRate, combinedRefSatRotRate, 3); - // Then substract the combined required satellite rotational rates from the actual rate - VectorOperations::subtract(currentSatRotRate, combinedRefSatRotRate, errorSatRotRate, - 3); - } else { - // If orientation has not been aquired yet set satellite rotational rate to zero - errorSatRotRate = 0; - } - - // target flag in matlab, importance, does look like it only gives feedback if pointing control is - // under 150 arcsec ?? + // Calculate error satellite rotational rate + // First combine the target and reference satellite rotational rates + double combinedRefSatRotRate[3] = {0, 0, 0}; + VectorOperations::add(targetSatRotRate, refSatRotRate, combinedRefSatRotRate, 3); + // Then subtract the combined required satellite rotational rates from the actual rate + VectorOperations::subtract(currentSatRotRate, combinedRefSatRotRate, errorSatRotRate, 3); } void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], double targetQuat[4], @@ -453,17 +444,8 @@ void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], do // Calculate error angle errorAngle = QuaternionOperations::getAngle(errorQuat, true); - // Only give back error satellite rotational rate if orientation has already been aquired - if (errorAngle < 2. / 180. * M_PI) { - // Then substract the combined required satellite rotational rates from the actual rate - VectorOperations::subtract(currentSatRotRate, targetSatRotRate, errorSatRotRate, 3); - } else { - // If orientation has not been aquired yet set satellite rotational rate to zero - errorSatRotRate = 0; - } - - // target flag in matlab, importance, does look like it only gives feedback if pointing control is - // under 150 arcsec ?? + // Calculate error satellite rotational rate + VectorOperations::subtract(currentSatRotRate, targetSatRotRate, errorSatRotRate, 3); } void Guidance::targetRotationRate(int8_t timeElapsedMax, timeval now, double quatInertialTarget[4], From bd15d7b0e2ec3da56ccda529ff09a82b14168bc1 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 13:28:59 +0200 Subject: [PATCH 119/172] fixed calculation of rotational rate for ptgCtrl which also is used for idle now --- mission/controller/acs/Guidance.cpp | 29 +++++++++++++++++------------ mission/controller/acs/Guidance.h | 7 ++++--- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/mission/controller/acs/Guidance.cpp b/mission/controller/acs/Guidance.cpp index 329c6bdc..98dd56fa 100644 --- a/mission/controller/acs/Guidance.cpp +++ b/mission/controller/acs/Guidance.cpp @@ -266,7 +266,8 @@ void Guidance::targetQuatPtgGs(timeval now, double posSatE[3], double sunDirI[3] targetRotationRate(timeElapsedMax, now, targetQuat, targetSatRotRate); } -void Guidance::targetQuatPtgSun(double sunDirI[3], double targetQuat[4], double refSatRate[3]) { +void Guidance::targetQuatPtgSun(timeval now, double sunDirI[3], double targetQuat[4], + double targetSatRotRate[3]) { //------------------------------------------------------------------------------------- // Calculation of target quaternion to sun //------------------------------------------------------------------------------------- @@ -296,9 +297,8 @@ void Guidance::targetQuatPtgSun(double sunDirI[3], double targetQuat[4], double //---------------------------------------------------------------------------- // Calculation of reference rotation rate //---------------------------------------------------------------------------- - refSatRate[0] = 0; - refSatRate[1] = 0; - refSatRate[2] = 0; + int8_t timeElapsedMax = acsParameters->gsTargetModeControllerParameters.timeElapsedMax; + targetRotationRate(timeElapsedMax, now, targetQuat, targetSatRotRate); } void Guidance::targetQuatPtgNadirSingleAxis(timeval now, double posSatE[3], double quatBI[4], @@ -453,20 +453,25 @@ void Guidance::targetRotationRate(int8_t timeElapsedMax, timeval now, double qua //------------------------------------------------------------------------------------- // Calculation of target rotation rate //------------------------------------------------------------------------------------- - double timeElapsed = now.tv_sec + now.tv_usec * pow(10, -6) - - (timeSavedQuaternion.tv_sec + - timeSavedQuaternion.tv_usec * pow((double)timeSavedQuaternion.tv_usec, -6)); + double timeElapsed = now.tv_sec + now.tv_usec * 1e-6 - + (timeSavedQuaternion.tv_sec + timeSavedQuaternion.tv_usec * 1e-6); + if (VectorOperations::norm(savedQuaternion, 4) == 0) { + std::memcpy(savedQuaternion, quatInertialTarget, sizeof(savedQuaternion)); + } if (timeElapsed < timeElapsedMax) { + double q[4] = {0, 0, 0, 0}, qS[4] = {0, 0, 0, 0}; + QuaternionOperations::inverse(quatInertialTarget, q); + QuaternionOperations::inverse(savedQuaternion, qS); double qDiff[4] = {0, 0, 0, 0}; - VectorOperations::subtract(quatInertialTarget, savedQuaternion, qDiff, 4); + VectorOperations::subtract(q, qS, qDiff, 4); VectorOperations::mulScalar(qDiff, 1 / timeElapsed, qDiff, 4); - double tgtQuatVec[3] = {quatInertialTarget[0], quatInertialTarget[1], quatInertialTarget[2]}, - qDiffVec[3] = {qDiff[0], qDiff[1], qDiff[2]}; + double tgtQuatVec[3] = {q[0], q[1], q[2]}; + double qDiffVec[3] = {qDiff[0], qDiff[1], qDiff[2]}; double sum1[3] = {0, 0, 0}, sum2[3] = {0, 0, 0}, sum3[3] = {0, 0, 0}, sum[3] = {0, 0, 0}; - VectorOperations::cross(quatInertialTarget, qDiff, sum1); + VectorOperations::cross(tgtQuatVec, qDiffVec, sum1); VectorOperations::mulScalar(tgtQuatVec, qDiff[3], sum2, 3); - VectorOperations::mulScalar(qDiffVec, quatInertialTarget[3], sum3, 3); + VectorOperations::mulScalar(qDiffVec, q[3], sum3, 3); VectorOperations::add(sum1, sum2, sum, 3); VectorOperations::subtract(sum, sum3, sum, 3); double omegaRefNew[3] = {0, 0, 0}; diff --git a/mission/controller/acs/Guidance.h b/mission/controller/acs/Guidance.h index 39e77456..7b81e411 100644 --- a/mission/controller/acs/Guidance.h +++ b/mission/controller/acs/Guidance.h @@ -15,7 +15,7 @@ class Guidance { void getTargetParamsSafe(double sunTargetSafe[3]); ReturnValue_t solarArrayDeploymentComplete(); - // Function to get the target quaternion and refence rotation rate from gps position and + // Function to get the target quaternion and reference rotation rate from gps position and // position of the ground station void targetQuatPtgSingleAxis(timeval now, double posSatE[3], double velSatE[3], double sunDirI[3], double refDirB[3], double quatBI[4], double targetQuat[4], @@ -25,9 +25,10 @@ class Guidance { void targetQuatPtgGs(timeval now, double posSatE[3], double sunDirI[3], double quatIX[4], double targetSatRotRate[3]); - // Function to get the target quaternion and refence rotation rate for sun pointing after ground + // Function to get the target quaternion and reference rotation rate for sun pointing after ground // station - void targetQuatPtgSun(double sunDirI[3], double targetQuat[4], double refSatRate[3]); + void targetQuatPtgSun(timeval now, double sunDirI[3], double targetQuat[4], + double targetSatRotRate[3]); // Function to get the target quaternion and refence rotation rate from gps position for Nadir // pointing From 487b6bf69083a08a5ed23bce273939e14e822a1c Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 13:29:25 +0200 Subject: [PATCH 120/172] frmt --- mission/controller/acs/control/PtgCtrl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index c978dafc..cfbf85ea 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -35,6 +35,7 @@ void PtgCtrl::ptgLaw(AcsParameters::PointingLawParameters *pointingLawParameters qErrorLaw[i] = std::abs(qError[i]); } } + double qErrorLawNorm = VectorOperations::norm(qErrorLaw, 3); double gain1 = cInt * omMax / qErrorLawNorm; From c64ea7f7e659eff1d712141fcf2853fa4270321d Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 14:22:20 +0200 Subject: [PATCH 121/172] fixed nullspace rwSpd range --- mission/controller/acs/control/PtgCtrl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mission/controller/acs/control/PtgCtrl.cpp b/mission/controller/acs/control/PtgCtrl.cpp index cfbf85ea..2f5847cc 100644 --- a/mission/controller/acs/control/PtgCtrl.cpp +++ b/mission/controller/acs/control/PtgCtrl.cpp @@ -102,6 +102,8 @@ void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawPara // concentrate RW speeds as vector and convert to double double speedRws[4] = {static_cast(speedRw0), static_cast(speedRw1), static_cast(speedRw2), static_cast(speedRw3)}; + VectorOperations::mulScalar(speedRws, 1e-1, speedRws, 4); + VectorOperations::mulScalar(speedRws, RPM_TO_RAD_PER_SEC, speedRws, 4); // calculate RPM offset utilizing the nullspace double rpmOffset[4] = {0, 0, 0, 0}; @@ -112,7 +114,6 @@ void PtgCtrl::ptgNullspace(AcsParameters::PointingLawParameters *pointingLawPara // calculate resulting angular momentum double rwAngMomentum[4] = {0, 0, 0, 0}, diffRwSpeed[4] = {0, 0, 0, 0}; VectorOperations::subtract(speedRws, rpmOffset, diffRwSpeed, 4); - VectorOperations::mulScalar(diffRwSpeed, 1e-1, diffRwSpeed, 4); VectorOperations::mulScalar(diffRwSpeed, acsParameters->rwHandlingParameters.inertiaWheel, rwAngMomentum, 4); From 099eb488ae6e4398e30fdfdea9cb1acb60369dba Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 17:37:47 +0200 Subject: [PATCH 122/172] who needs comments anyways --- mission/controller/acs/Guidance.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mission/controller/acs/Guidance.cpp b/mission/controller/acs/Guidance.cpp index 98dd56fa..1d82d317 100644 --- a/mission/controller/acs/Guidance.cpp +++ b/mission/controller/acs/Guidance.cpp @@ -518,10 +518,6 @@ ReturnValue_t Guidance::getDistributionMatrixRw(ACS::SensorValues *sensorValues, std::memcpy(rwPseudoInv, acsParameters->rwMatrices.without4, 12 * sizeof(double)); return returnvalue::OK; } else { - // @note: This one takes the normal pseudoInverse of all four raction wheels valid. - // Does not make sense, but is implemented that way in MATLAB ?! - // Thought: It does not really play a role, because in case there are more then one - // reaction wheel invalid the pointing control is destined to fail. return returnvalue::FAILED; } } From a58f51ee91bfda9c46f54f12c57e5f10551d5634 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 17:41:25 +0200 Subject: [PATCH 123/172] small fixes --- mission/controller/AcsController.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 557a6105..8b3eee64 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -368,9 +368,11 @@ void AcsController::performPointingCtrl() { // Variables required for setting actuators double torquePtgRws[4] = {0, 0, 0, 0}, rwTrqNs[4] = {0, 0, 0, 0}, torqueRws[4] = {0, 0, 0, 0}, mgtDpDes[3] = {0, 0, 0}; + switch (mode) { case acs::PTG_IDLE: - guidance.targetQuatPtgSun(susDataProcessed.sunIjkModel.value, targetQuat, targetSatRotRate); + guidance.targetQuatPtgSun(now, susDataProcessed.sunIjkModel.value, targetQuat, + targetSatRotRate); guidance.comparePtg(mekfData.quatMekf.value, mekfData.satRotRateMekf.value, targetQuat, targetSatRotRate, errorQuat, errorSatRotRate, errorAngle); ptgCtrl.ptgLaw(&acsParameters.idleModeControllerParameters, errorQuat, errorSatRotRate, @@ -460,7 +462,7 @@ void AcsController::performPointingCtrl() { case acs::PTG_INERTIAL: std::memcpy(targetQuat, acsParameters.inertialModeControllerParameters.tgtQuat, - 4 * sizeof(double)); + sizeof(targetQuat)); guidance.comparePtg(mekfData.quatMekf.value, mekfData.satRotRateMekf.value, targetQuat, targetSatRotRate, acsParameters.inertialModeControllerParameters.quatRef, acsParameters.inertialModeControllerParameters.refRotRate, errorQuat, From 6915f0e003df40cda0302ee1f58b59842a4fd83f Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 2 Jun 2023 17:45:08 +0200 Subject: [PATCH 124/172] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7890df35..88423f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ will consitute of a breaking change warranting a new major release: - ACU dummy HK sets - IMTQ HK sets - IMTQ dummy now handles power switch +- Added some new ACS parameters ## Fixed @@ -91,6 +92,8 @@ will consitute of a breaking change warranting a new major release: - Prevent spam of TCS controller heater unavailability event if all heaters are in external control. - TCS heater switch info set contained invalid values because of a faulty `memcpy` in the TCS controller. There is not crash risk but the heater states were invalid. +- Various fixes for the pointing modes of the `ACS Controller`. All modes should work now as + intended. # [v2.0.5] 2023-05-11 From 5a60558354c6d24249836189705ad1a455acbda9 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 09:24:52 +0200 Subject: [PATCH 125/172] set relevant datasets to invalid on shutdown --- mission/acs/str/StarTrackerHandler.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 0942164a..037cc871 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -100,6 +100,19 @@ void StarTrackerHandler::doShutDown() { startupState = StartupState::IDLE; bootState = FwBootState::NONE; solutionSet.setReportingEnabled(false); + { + PoolReadGuard& pg(solutionSet); + solutionSet.caliQw.value = 0.0; + solutionSet.caliQx.value = 0.0; + solutionSet.caliQy.value = 0.0; + solutionSet.caliQz.value = 0.0; + solutionSet.isTrustWorthy = 0; + solutionSet.setValidity(false, true); + } + { + PoolReadGuard& pg(temperatureSet); + temperatureSet.setValidity(false, true); + } reinitNextSetParam = false; setMode(_MODE_POWER_DOWN); } From 73981006a2a3e0580a8b13ab1b709ab0c9d26e39 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 09:25:31 +0200 Subject: [PATCH 126/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7890df35..455b7373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,6 +91,7 @@ will consitute of a breaking change warranting a new major release: - Prevent spam of TCS controller heater unavailability event if all heaters are in external control. - TCS heater switch info set contained invalid values because of a faulty `memcpy` in the TCS controller. There is not crash risk but the heater states were invalid. +- STR datasets were not set to invalid on shutdown. # [v2.0.5] 2023-05-11 From a1fec93b25edbb23b7891af5d1677c32e0d0e506 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 16:02:01 +0200 Subject: [PATCH 127/172] fix --- mission/acs/str/StarTrackerHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 037cc871..cf2a5919 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -101,7 +101,7 @@ void StarTrackerHandler::doShutDown() { bootState = FwBootState::NONE; solutionSet.setReportingEnabled(false); { - PoolReadGuard& pg(solutionSet); + PoolReadGuard pg(&solutionSet); solutionSet.caliQw.value = 0.0; solutionSet.caliQx.value = 0.0; solutionSet.caliQy.value = 0.0; @@ -110,7 +110,7 @@ void StarTrackerHandler::doShutDown() { solutionSet.setValidity(false, true); } { - PoolReadGuard& pg(temperatureSet); + PoolReadGuard pg(&temperatureSet); temperatureSet.setValidity(false, true); } reinitNextSetParam = false; From 939eeb09ec2a14f6d84d0e42fa186d4e7fd79e5a Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 09:37:01 +0200 Subject: [PATCH 128/172] fixed str validity check --- mission/controller/acs/Navigation.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mission/controller/acs/Navigation.cpp b/mission/controller/acs/Navigation.cpp index 9e8b3719..7c822409 100644 --- a/mission/controller/acs/Navigation.cpp +++ b/mission/controller/acs/Navigation.cpp @@ -19,9 +19,7 @@ ReturnValue_t Navigation::useMekf(ACS::SensorValues *sensorValues, acsctrl::MekfData *mekfData, AcsParameters *acsParameters) { double quatIB[4] = {sensorValues->strSet.caliQx.value, sensorValues->strSet.caliQy.value, sensorValues->strSet.caliQz.value, sensorValues->strSet.caliQw.value}; - bool quatIBValid = sensorValues->strSet.caliQx.isValid() && - sensorValues->strSet.caliQy.isValid() && - sensorValues->strSet.caliQz.isValid() && sensorValues->strSet.caliQw.isValid(); + bool quatIBValid = sensorValues->strSet.isTrustWorthy.value; if (mekfStatus == MultiplicativeKalmanFilter::MEKF_UNINITIALIZED) { mekfStatus = multiplicativeKalmanFilter.init( From a5f9bb31774e285e1bf1bb4066c202d7eea4c052 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 09:43:31 +0200 Subject: [PATCH 129/172] reworked multiple rw failure handling --- mission/controller/AcsController.cpp | 3 ++- mission/controller/acs/AcsParameters.cpp | 3 +++ mission/controller/acs/AcsParameters.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 0b49de04..2faa0f64 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -349,7 +349,8 @@ void AcsController::performPointingCtrl() { double rwPseudoInv[4][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; result = guidance.getDistributionMatrixRw(&sensorValues, *rwPseudoInv); if (result == returnvalue::FAILED) { - if (multipleRwUnavailableCounter == 5) { + if (multipleRwUnavailableCounter >= + acsParameters.rwHandlingParameters.multipleRwInvalidTimeout) { triggerEvent(acs::MULTIPLE_RW_INVALID); } multipleRwUnavailableCounter++; diff --git a/mission/controller/acs/AcsParameters.cpp b/mission/controller/acs/AcsParameters.cpp index 792a72ec..d516aebd 100644 --- a/mission/controller/acs/AcsParameters.cpp +++ b/mission/controller/acs/AcsParameters.cpp @@ -290,6 +290,9 @@ ReturnValue_t AcsParameters::getParameter(uint8_t domainId, uint8_t parameterId, case 0x6: parameterWrapper->set(rwHandlingParameters.rampTime); break; + case 0x7: + parameterWrapper->set(rwHandlingParameters.multipleRwInvalidTimeout); + break; default: return INVALID_IDENTIFIER_ID; } diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index 9600ca7e..7034c9ae 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -798,6 +798,8 @@ class AcsParameters : public HasParametersIF { double stictionTorque = 0.0006; uint16_t rampTime = 10; + + uint32_t multipleRwInvalidTimeout = 25; } rwHandlingParameters; struct RwMatrices { From 58dee642a6a3296a7fdb08ef3e5468bbccd231da Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 16:06:36 +0200 Subject: [PATCH 130/172] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7890df35..759046bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ will consitute of a breaking change warranting a new major release: reason. - OFF mode is ignores in TM store for determining whether a store will be written. The modes will only be used to cancel a transfer. +- Handling of multiple RWs in the ACS Controller is improved and can be changed by parameter + commands. ## Added @@ -91,6 +93,8 @@ will consitute of a breaking change warranting a new major release: - Prevent spam of TCS controller heater unavailability event if all heaters are in external control. - TCS heater switch info set contained invalid values because of a faulty `memcpy` in the TCS controller. There is not crash risk but the heater states were invalid. +- Fixed usage of quaternion valid flag, which does not actually represent the validity of the + quaternion. # [v2.0.5] 2023-05-11 From d4b44962f5fce9e1897f4510bc225ac4ead4e7b9 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 5 Jun 2023 16:08:53 +0200 Subject: [PATCH 131/172] prevent 0.4s spam --- mission/controller/AcsController.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 2faa0f64..15e9a840 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -352,6 +352,7 @@ void AcsController::performPointingCtrl() { if (multipleRwUnavailableCounter >= acsParameters.rwHandlingParameters.multipleRwInvalidTimeout) { triggerEvent(acs::MULTIPLE_RW_INVALID); + multipleRwUnavailableCounter = 0; } multipleRwUnavailableCounter++; return; From 8052734028efc0d98b7bbd438a97bea3b63e3aa4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Jun 2023 11:12:41 +0200 Subject: [PATCH 132/172] tiny tweak --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30376485..d224e629 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ will consitute of a breaking change warranting a new major release: # [unreleased] -# [v2.2.0] to be released +# [v4.0.0] to be released # [v3.0.0] to be released From 6a2d5b81612defbb79089977e6f4da25487575aa Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 6 Jun 2023 16:02:11 +0200 Subject: [PATCH 133/172] well this doesnt work --- linux/acs/AcsBoardPolling.cpp | 89 ++++++++++++++++++++++++++++- linux/acs/AcsBoardPolling.h | 3 + mission/acs/GyrAdis1650XHandler.cpp | 12 ++-- mission/acs/GyrAdis1650XHandler.h | 2 +- mission/acs/acsBoardPolling.h | 11 ++-- mission/acs/gyroAdisHelpers.cpp | 11 ++++ mission/acs/gyroAdisHelpers.h | 2 + 7 files changed, 118 insertions(+), 12 deletions(-) diff --git a/linux/acs/AcsBoardPolling.cpp b/linux/acs/AcsBoardPolling.cpp index e525bf53..38bf4351 100644 --- a/linux/acs/AcsBoardPolling.cpp +++ b/linux/acs/AcsBoardPolling.cpp @@ -113,6 +113,7 @@ ReturnValue_t AcsBoardPolling::sendMessage(CookieIF* cookie, const uint8_t* send if (req->mode != adis.mode) { if (req->mode == acs::SimpleSensorMode::NORMAL) { adis.type = req->type; + adis.decRate = req->cfg.decRateReg; // The initial countdown is handled by the device handler now. // adis.countdown.setTimeout(adis1650x::START_UP_TIME); if (adis.type == adis1650x::Type::ADIS16507) { @@ -376,6 +377,81 @@ void AcsBoardPolling::gyroL3gHandler(GyroL3g& l3g) { } } +ReturnValue_t AcsBoardPolling::writeAdisReg(SpiCookie& cookie) { + ReturnValue_t result = returnvalue::OK; + int retval = 0; + // Prepare transfer + int fileDescriptor = 0; + std::string device = spiComIF.getSpiDev(); + UnixFileGuard fileHelper(device, fileDescriptor, O_RDWR, "SpiComIF::sendMessage"); + if (fileHelper.getOpenResult() != returnvalue::OK) { + return spi::OPENING_FILE_FAILED; + } + spi::SpiModes spiMode = spi::SpiModes::MODE_0; + uint32_t spiSpeed = 0; + cookie.getSpiParameters(spiMode, spiSpeed, nullptr); + spiComIF.setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); + cookie.assignWriteBuffer(cmdBuf.data()); + cookie.setTransferSize(2); + + gpioId_t gpioId = cookie.getChipSelectPin(); + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t timeoutMs = 0; + MutexIF* mutex = spiComIF.getCsMutex(); + cookie.getMutexParams(timeoutType, timeoutMs); + if (mutex == nullptr) { + sif::warning << "GyroADIS16507Handler::spiSendCallback: " + "Mutex or GPIO interface invalid" + << std::endl; + return returnvalue::FAILED; + } + + size_t idx = 0; + spi_ioc_transfer* transferStruct = cookie.getTransferStructHandle(); + uint64_t origTx = transferStruct->tx_buf; + uint64_t origRx = transferStruct->rx_buf; + for (idx = 0; idx < 2; idx++) { + result = mutex->lockMutex(timeoutType, timeoutMs); + if (result != returnvalue::OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "AcsBoardPolling: Failed to lock mutex" << std::endl; +#endif + return result; + } + // Pull SPI CS low. For now, no support for active high given + if (gpioId != gpio::NO_GPIO) { + gpioIF.pullLow(gpioId); + } + + // Execute transfer + // Initiate a full duplex SPI transfer. + retval = ioctl(fileDescriptor, SPI_IOC_MESSAGE(1), cookie.getTransferStructHandle()); + if (retval < 0) { + utility::handleIoctlError("SpiComIF::sendMessage: ioctl error."); + result = spi::FULL_DUPLEX_TRANSFER_FAILED; + } +#if FSFW_HAL_SPI_WIRETAPPING == 1 + comIf->performSpiWiretapping(cookie); +#endif /* FSFW_LINUX_SPI_WIRETAPPING == 1 */ + + if (gpioId != gpio::NO_GPIO) { + gpioIF.pullHigh(gpioId); + } + mutex->unlockMutex(); + + idx += 2; + transferStruct->tx_buf += 2; + transferStruct->rx_buf += 2; + if (idx < 4) { + usleep(adis1650x::STALL_TIME_MICROSECONDS); + } + } + transferStruct->tx_buf = origTx; + transferStruct->rx_buf = origRx; + cookie.setTransferSize(0); + return returnvalue::OK; +} + ReturnValue_t AcsBoardPolling::readAdisCfg(SpiCookie& cookie, size_t transferLen) { ReturnValue_t result = returnvalue::OK; int retval = 0; @@ -455,15 +531,20 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { ReturnValue_t result; acs::SimpleSensorMode mode = acs::SimpleSensorMode::OFF; bool mustPerformStartup = false; + uint16_t decRate = 0; { MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); mode = gyro.mode; + decRate = gyro.decRate; mustPerformStartup = gyro.performStartup; } if (mode == acs::SimpleSensorMode::OFF) { return; } if (mustPerformStartup) { + adis1650x::prepareWriteRegCommand(adis1650x::DEC_RATE_REG, decRate, cmdBuf.data(), + cmdBuf.size()); + writeAdisReg(*gyro.cookie); uint8_t regList[6]; // Read configuration regList[0] = adis1650x::DIAG_STAT_REG; @@ -491,13 +572,19 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { gyro.replyResult = returnvalue::FAILED; return; } + uint16_t decRateReadBack = (rawReply[10] << 8) | rawReply[11]; + if (decRateReadBack != decRate) { + sif::warning << "AcsPollingTask: DEC rate configuration failed. Read " << decRateReadBack + << ", expected " << decRate << std::endl; + gyro.replyResult = returnvalue::FAILED; + } MutexGuard mg(ipcLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); gyro.ownReply.cfgWasSet = true; gyro.ownReply.cfg.diagStat = (rawReply[2] << 8) | rawReply[3]; gyro.ownReply.cfg.filterSetting = (rawReply[4] << 8) | rawReply[5]; gyro.ownReply.cfg.rangMdl = (rawReply[6] << 8) | rawReply[7]; gyro.ownReply.cfg.mscCtrlReg = (rawReply[8] << 8) | rawReply[9]; - gyro.ownReply.cfg.decRateReg = (rawReply[10] << 8) | rawReply[11]; + gyro.ownReply.cfg.decRateReg = decRateReadBack; gyro.ownReply.cfg.prodId = prodId; gyro.ownReply.data.sensitivity = adis1650x::rangMdlToSensitivity(gyro.ownReply.cfg.rangMdl); gyro.performStartup = false; diff --git a/linux/acs/AcsBoardPolling.h b/linux/acs/AcsBoardPolling.h index 794c9c47..5b4d0390 100644 --- a/linux/acs/AcsBoardPolling.h +++ b/linux/acs/AcsBoardPolling.h @@ -37,6 +37,7 @@ class AcsBoardPolling : public SystemObject, struct GyroAdis : public DevBase { adis1650x::Type type; + uint16_t decRate; Countdown countdown; acs::Adis1650XReply ownReply; acs::Adis1650XReply readerReply; @@ -84,6 +85,8 @@ class AcsBoardPolling : public SystemObject, void gyroAdisHandler(GyroAdis& gyro); void mgmLis3Handler(MgmLis3& mgm); void mgmRm3100Handler(MgmRm3100& mgm); + // This fumction configures the register as specified on p.21 of the datasheet. + ReturnValue_t writeAdisReg(SpiCookie& cookie); // Special readout: 16us stall time between small 2 byte transfers. ReturnValue_t readAdisCfg(SpiCookie& spiCookie, size_t transferLen); }; diff --git a/mission/acs/GyrAdis1650XHandler.cpp b/mission/acs/GyrAdis1650XHandler.cpp index c61187ce..27e8dc75 100644 --- a/mission/acs/GyrAdis1650XHandler.cpp +++ b/mission/acs/GyrAdis1650XHandler.cpp @@ -26,11 +26,11 @@ void GyrAdis1650XHandler::doStartUp() { breakCountdown.setTimeout(adis1650x::START_UP_TIME); commandExecuted = true; } - if (breakCountdown.hasTimedOut()) { - updatePeriodicReply(true, adis1650x::REPLY); - setMode(MODE_ON); - internalState = InternalState::NONE; - } + } + if (internalState == InternalState::STARTUP_DONE) { + updatePeriodicReply(true, adis1650x::REPLY); + setMode(MODE_ON); + internalState = InternalState::NONE; } } @@ -61,6 +61,8 @@ ReturnValue_t GyrAdis1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_ return NOTHING_TO_SEND; } *id = adis1650x::REQUEST; + adisRequest.cfg.decRateReg = adis1650x::DEC_RATE; + internalState = InternalState::STARTUP_DONE; return preparePeriodicRequest(acs::SimpleSensorMode::NORMAL); } case (InternalState::SHUTDOWN): { diff --git a/mission/acs/GyrAdis1650XHandler.h b/mission/acs/GyrAdis1650XHandler.h index 5d906f61..308d472b 100644 --- a/mission/acs/GyrAdis1650XHandler.h +++ b/mission/acs/GyrAdis1650XHandler.h @@ -48,7 +48,7 @@ class GyrAdis1650XHandler : public DeviceHandlerBase { bool warningSwitch = true; - enum class InternalState { NONE, STARTUP, SHUTDOWN }; + enum class InternalState { NONE, STARTUP, STARTUP_DONE, SHUTDOWN }; InternalState internalState = InternalState::STARTUP; bool commandExecuted = false; diff --git a/mission/acs/acsBoardPolling.h b/mission/acs/acsBoardPolling.h index 90f0f19c..9f794fb0 100644 --- a/mission/acs/acsBoardPolling.h +++ b/mission/acs/acsBoardPolling.h @@ -8,11 +8,6 @@ namespace acs { -struct Adis1650XRequest { - SimpleSensorMode mode; - adis1650x::Type type; -}; - struct Adis1650XConfig { uint16_t diagStat; uint16_t filterSetting; @@ -22,6 +17,12 @@ struct Adis1650XConfig { uint16_t prodId; }; +struct Adis1650XRequest { + SimpleSensorMode mode; + adis1650x::Type type; + Adis1650XConfig cfg; +}; + struct Adis1650XData { double sensitivity = 0.0; // Angular velocities in all axes (X, Y and Z) diff --git a/mission/acs/gyroAdisHelpers.cpp b/mission/acs/gyroAdisHelpers.cpp index 0f41b058..5dd3a217 100644 --- a/mission/acs/gyroAdisHelpers.cpp +++ b/mission/acs/gyroAdisHelpers.cpp @@ -52,3 +52,14 @@ double adis1650x::rangMdlToSensitivity(uint16_t rangMdl) { } } } + +void adis1650x::prepareWriteRegCommand(uint8_t regStart, uint16_t val, uint8_t* outBuf, + size_t maxLen) { + if (maxLen < 4) { + return; + } + outBuf[0] = regStart | adis1650x::WRITE_MASK; + outBuf[1] = val & 0Xff; + outBuf[2] = (regStart + 1) | adis1650x::WRITE_MASK; + outBuf[3] = (val >> 8) & 0xff; +} diff --git a/mission/acs/gyroAdisHelpers.h b/mission/acs/gyroAdisHelpers.h index c8a28369..00fda595 100644 --- a/mission/acs/gyroAdisHelpers.h +++ b/mission/acs/gyroAdisHelpers.h @@ -16,6 +16,8 @@ enum class BurstModes { }; size_t prepareReadCommand(const uint8_t* regList, size_t len, uint8_t* outBuf, size_t maxLen); +void prepareWriteRegCommand(uint8_t regStart, uint16_t val, uint8_t* outBuf, size_t maxLen); + BurstModes burstModeFromMscCtrl(uint16_t mscCtrl); double rangMdlToSensitivity(uint16_t rangMdl); From 72b5567f73ee1370503fbd6796edc2e2d89d25b3 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 09:17:49 +0200 Subject: [PATCH 134/172] not that it matters --- mission/acs/gyroAdisHelpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/acs/gyroAdisHelpers.cpp b/mission/acs/gyroAdisHelpers.cpp index 5dd3a217..5c1446cc 100644 --- a/mission/acs/gyroAdisHelpers.cpp +++ b/mission/acs/gyroAdisHelpers.cpp @@ -59,7 +59,7 @@ void adis1650x::prepareWriteRegCommand(uint8_t regStart, uint16_t val, uint8_t* return; } outBuf[0] = regStart | adis1650x::WRITE_MASK; - outBuf[1] = val & 0Xff; + outBuf[1] = val & 0xff; outBuf[2] = (regStart + 1) | adis1650x::WRITE_MASK; outBuf[3] = (val >> 8) & 0xff; } From 7dbe69ef49be7d86e50880a1cc4fe2074c9e72e0 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 09:20:29 +0200 Subject: [PATCH 135/172] now he reads the comments ... what happened to him --- mission/controller/acs/ActuatorCmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 9013d6f2..0fb8bdf5 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -25,7 +25,7 @@ void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, const double sampleTime, const double inertiaWheel, const int32_t maxRwSpeed, const double *rwTorque, int32_t *rwCmdSpeed) { - // concentrate RW speed values (in 0.1 [RPM]) in vector + // group RW speed values (in 0.1 [RPM]) in vector int32_t speedRws[4] = {speedRw0, speedRw1, speedRw2, speedRw3}; // calculate required RW speed as sum of current RW speed and RW speed delta From f4c9a4bda22edd0df6fc60f6a2bab612499853f3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 11:38:02 +0200 Subject: [PATCH 136/172] fix for indexing --- linux/acs/AcsBoardPolling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/acs/AcsBoardPolling.cpp b/linux/acs/AcsBoardPolling.cpp index 38bf4351..811c6a72 100644 --- a/linux/acs/AcsBoardPolling.cpp +++ b/linux/acs/AcsBoardPolling.cpp @@ -410,7 +410,7 @@ ReturnValue_t AcsBoardPolling::writeAdisReg(SpiCookie& cookie) { spi_ioc_transfer* transferStruct = cookie.getTransferStructHandle(); uint64_t origTx = transferStruct->tx_buf; uint64_t origRx = transferStruct->rx_buf; - for (idx = 0; idx < 2; idx++) { + for (idx = 0; idx < 4; idx++) { result = mutex->lockMutex(timeoutType, timeoutMs); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 From a110bf32aa25d36284b28550e1c3e2548c8aaa5b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 11:46:23 +0200 Subject: [PATCH 137/172] another small fix --- linux/acs/AcsBoardPolling.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux/acs/AcsBoardPolling.cpp b/linux/acs/AcsBoardPolling.cpp index 811c6a72..1ba55357 100644 --- a/linux/acs/AcsBoardPolling.cpp +++ b/linux/acs/AcsBoardPolling.cpp @@ -410,7 +410,7 @@ ReturnValue_t AcsBoardPolling::writeAdisReg(SpiCookie& cookie) { spi_ioc_transfer* transferStruct = cookie.getTransferStructHandle(); uint64_t origTx = transferStruct->tx_buf; uint64_t origRx = transferStruct->rx_buf; - for (idx = 0; idx < 4; idx++) { + for (idx = 0; idx < 4; idx += 2) { result = mutex->lockMutex(timeoutType, timeoutMs); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -439,7 +439,6 @@ ReturnValue_t AcsBoardPolling::writeAdisReg(SpiCookie& cookie) { } mutex->unlockMutex(); - idx += 2; transferStruct->tx_buf += 2; transferStruct->rx_buf += 2; if (idx < 4) { From 9aec8960b980502b5d9a1c75eaf9a6c1f66f2188 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 13:43:23 +0200 Subject: [PATCH 138/172] hi --- fsfw | 2 +- mission/genericFactory.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 5eb9ee8b..9903371a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5eb9ee8bc1e6f8640cbea46febd11e4b92241881 +Subproject commit 9903371ae9040a8171ead9cda9c8c73177d03d71 diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index 2dd00ee6..4ec4adec 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -243,7 +243,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, config::EIVE_PUS_APID, pus::PUS_SERVICE_5), 80, 160); new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, config::EIVE_PUS_APID, - pus::PUS_SERVICE_8, 16, 60); + pus::PUS_SERVICE_8, 16, 60, 50); new Service9TimeManagement( PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, config::EIVE_PUS_APID, pus::PUS_SERVICE_9)); From 5ca96b2dd359bdd967fd2c82c23e75028b135507 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 13:49:12 +0200 Subject: [PATCH 139/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 9903371a..b442ca09 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9903371ae9040a8171ead9cda9c8c73177d03d71 +Subproject commit b442ca09b91d0cfdc6acd5a30349a25c4051972c From b8064c4a39971b63b445d5b15ea106d71e54146d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 13:50:11 +0200 Subject: [PATCH 140/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 4391823f..9372b2a5 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 4391823f01d792bcc078d47b60f7df7624f8cbe4 +Subproject commit 9372b2a575aaa3a2c9e93d6e745a4e3fd08d0004 From 4bcfb8f5a2c9a14f8fcc8fd5f903eead54e8d0b6 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 14:13:32 +0200 Subject: [PATCH 141/172] still doesnt work --- linux/acs/AcsBoardPolling.cpp | 3 +++ mission/acs/GyrAdis1650XHandler.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/linux/acs/AcsBoardPolling.cpp b/linux/acs/AcsBoardPolling.cpp index 1ba55357..727e8405 100644 --- a/linux/acs/AcsBoardPolling.cpp +++ b/linux/acs/AcsBoardPolling.cpp @@ -572,6 +572,8 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { return; } uint16_t decRateReadBack = (rawReply[10] << 8) | rawReply[11]; + sif::debug << "AcsPollingTask: DEC rate configuration. Read " << decRateReadBack + << ", expected " << decRate << std::endl; if (decRateReadBack != decRate) { sif::warning << "AcsPollingTask: DEC rate configuration failed. Read " << decRateReadBack << ", expected " << decRate << std::endl; @@ -589,6 +591,7 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { gyro.performStartup = false; gyro.replyResult = returnvalue::OK; } + sif::debug << "hello world 2" << std::endl; // Read regular registers std::memcpy(cmdBuf.data(), adis1650x::BURST_READ_ENABLE.data(), adis1650x::BURST_READ_ENABLE.size()); diff --git a/mission/acs/GyrAdis1650XHandler.cpp b/mission/acs/GyrAdis1650XHandler.cpp index 27e8dc75..6f447178 100644 --- a/mission/acs/GyrAdis1650XHandler.cpp +++ b/mission/acs/GyrAdis1650XHandler.cpp @@ -26,9 +26,9 @@ void GyrAdis1650XHandler::doStartUp() { breakCountdown.setTimeout(adis1650x::START_UP_TIME); commandExecuted = true; } + updatePeriodicReply(true, adis1650x::REPLY); } if (internalState == InternalState::STARTUP_DONE) { - updatePeriodicReply(true, adis1650x::REPLY); setMode(MODE_ON); internalState = InternalState::NONE; } From 06b381d965eae30e0a96203bcfe807d96a0d7c1d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 14:20:58 +0200 Subject: [PATCH 142/172] dir listing dump state machine --- bsp_q7s/core/CoreController.cpp | 92 ++++++++++++++++++++++------ bsp_q7s/core/CoreController.h | 14 +++++ mission/controller/acs/ActuatorCmd.h | 1 - 3 files changed, 87 insertions(+), 20 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 5c4c4d62..9b6a22b0 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -112,6 +112,9 @@ void CoreController::performControlOperation() { sdStateMachine(); performMountedSdCardOperations(); readHkData(); + if (dumpContext.active) { + dirListingDumpHandler(); + } if (shellCmdIsExecuting) { bool replyReceived = false; @@ -1038,7 +1041,6 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI return returnvalue::FAILED; } } - std::array dirListingBuf{}; dirListingBuf[8] = parser.compressionOptionSet(); // First four bytes reserved for segment index. One byte for compression option information std::strcpy(reinterpret_cast(dirListingBuf.data() + 2 * sizeof(uint32_t) + 1), repoName); @@ -1047,38 +1049,46 @@ 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(dirListingBuf.data() + listingDataOffset), nextDumpLen); + SerializeAdapter::serialize(&dumpContext.segmentIdx, dirListingBuf.data(), &dummy, + dirListingBuf.size(), SerializeIF::Endianness::NETWORK); + ifile.read(reinterpret_cast(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 == 25) { + dumpContext.active = 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); @@ -2346,6 +2356,50 @@ MessageQueueId_t CoreController::getCommandQueue() const { return ExtendedControllerBase::getCommandQueue(); } +void CoreController::dirListingDumpHandler() { + 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(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 == 25) { + 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(); diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index d44907e8..a58faf86 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -177,6 +177,19 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe DeviceCommandId_t actionId; } sdCommandingInfo; + struct DirListingDumpContext { + bool active; + size_t dumpedBytes; + size_t totalFileSize; + size_t listingDataOffset; + size_t maxDumpLen; + uint32_t segmentIdx; + MessageQueueId_t commander = MessageQueueIF::NO_QUEUE; + DeviceCommandId_t actionId; + }; + std::array dirListingBuf{}; + DirListingDumpContext dumpContext{}; + RebootFile rebootFile = {}; CommandExecutor cmdExecutor; @@ -274,6 +287,7 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe void rewriteRebootFile(RebootFile file); void announceBootCounts(); void readHkData(); + void dirListingDumpHandler(); bool isNumber(const std::string& s); }; diff --git a/mission/controller/acs/ActuatorCmd.h b/mission/controller/acs/ActuatorCmd.h index 6a1b3dbb..b14a4a25 100644 --- a/mission/controller/acs/ActuatorCmd.h +++ b/mission/controller/acs/ActuatorCmd.h @@ -3,7 +3,6 @@ #include - class ActuatorCmd { public: ActuatorCmd(); From 26ed774806767952cd3ba058312210a5841e634c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 14:25:13 +0200 Subject: [PATCH 143/172] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17ac5d5d..d686359d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,9 @@ will consitute of a breaking change warranting a new major release: only be used to cancel a transfer. - Handling of multiple RWs in the ACS Controller is improved and can be changed by parameter commands. +- The Directory Listing direct dumper now has a state machine to stagger the directory listing dump. + This is required because very large dumps will overload the queue capacities in the framework. +- The PUS Service 8 now has larger queue sizes to handle more action replies. ## Added From 06c5344d8a44b0cd73209c1fc649ca6713a5622a Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 15:14:03 +0200 Subject: [PATCH 144/172] this might actually work --- linux/acs/AcsBoardPolling.cpp | 1 - mission/acs/GyrAdis1650XHandler.cpp | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/linux/acs/AcsBoardPolling.cpp b/linux/acs/AcsBoardPolling.cpp index 727e8405..b8539a8f 100644 --- a/linux/acs/AcsBoardPolling.cpp +++ b/linux/acs/AcsBoardPolling.cpp @@ -591,7 +591,6 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { gyro.performStartup = false; gyro.replyResult = returnvalue::OK; } - sif::debug << "hello world 2" << std::endl; // Read regular registers std::memcpy(cmdBuf.data(), adis1650x::BURST_READ_ENABLE.data(), adis1650x::BURST_READ_ENABLE.size()); diff --git a/mission/acs/GyrAdis1650XHandler.cpp b/mission/acs/GyrAdis1650XHandler.cpp index 6f447178..fe10c214 100644 --- a/mission/acs/GyrAdis1650XHandler.cpp +++ b/mission/acs/GyrAdis1650XHandler.cpp @@ -15,7 +15,7 @@ GyrAdis1650XHandler::GyrAdis1650XHandler(object_id_t objectId, object_id_t devic } void GyrAdis1650XHandler::doStartUp() { - if (internalState != InternalState::STARTUP) { + if (internalState == InternalState::NONE) { internalState = InternalState::STARTUP; commandExecuted = false; } @@ -24,12 +24,13 @@ void GyrAdis1650XHandler::doStartUp() { if (not commandExecuted) { warningSwitch = true; breakCountdown.setTimeout(adis1650x::START_UP_TIME); + updatePeriodicReply(true, adis1650x::REPLY); commandExecuted = true; } - updatePeriodicReply(true, adis1650x::REPLY); } if (internalState == InternalState::STARTUP_DONE) { setMode(MODE_ON); + commandExecuted = false; internalState = InternalState::NONE; } } @@ -62,7 +63,6 @@ ReturnValue_t GyrAdis1650XHandler::buildTransitionDeviceCommand(DeviceCommandId_ } *id = adis1650x::REQUEST; adisRequest.cfg.decRateReg = adis1650x::DEC_RATE; - internalState = InternalState::STARTUP_DONE; return preparePeriodicRequest(acs::SimpleSensorMode::NORMAL); } case (InternalState::SHUTDOWN): { @@ -93,6 +93,9 @@ ReturnValue_t GyrAdis1650XHandler::scanForReply(const uint8_t *start, size_t rem getMode() == _MODE_POWER_DOWN) { return IGNORE_FULL_PACKET; } + if (internalState == InternalState::STARTUP) { + internalState = InternalState::STARTUP_DONE; + } *foundLen = remainingSize; if (remainingSize != sizeof(acs::Adis1650XReply)) { return returnvalue::FAILED; From dcf3b1b1fee30d09beb40359af7536fdad8b60d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 15:55:26 +0200 Subject: [PATCH 145/172] added debug statement for testing --- bsp_q7s/core/CoreController.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 9b6a22b0..3c86915f 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1080,6 +1080,7 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e); return result; } + sif::debug << "dumped segment " << dumpContext.segmentIdx << std::endl; dumpContext.segmentIdx++; dumpContext.dumpedBytes += nextDumpLen; // Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles. @@ -2385,6 +2386,7 @@ void CoreController::dirListingDumpHandler() { actionHelper.finish(false, dumpContext.commander, dumpContext.actionId, result); return; } + sif::debug << "dumped segment " << dumpContext.segmentIdx << std::endl; dumpContext.segmentIdx++; dumpContext.dumpedBytes += nextDumpLen; // Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles. From deb154770d0d5b7cdbaa90cf4e71e82d9ebac242 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Jun 2023 16:21:51 +0200 Subject: [PATCH 146/172] increased service 1 queue depth --- bsp_q7s/core/CoreController.cpp | 9 +++++++-- bsp_q7s/core/CoreController.h | 1 + common/config/eive/definitions.h | 1 + mission/genericFactory.cpp | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 3c86915f..3304fce8 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1084,8 +1084,9 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI dumpContext.segmentIdx++; dumpContext.dumpedBytes += nextDumpLen; // Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles. - if (dumpContext.segmentIdx == 25) { + if (dumpContext.segmentIdx == 10) { dumpContext.active = true; + dumpContext.firstDump = true; dumpContext.commander = commandedBy; dumpContext.actionId = actionId; return returnvalue::OK; @@ -2358,6 +2359,10 @@ MessageQueueId_t CoreController::getCommandQueue() const { } void CoreController::dirListingDumpHandler() { + if (dumpContext.firstDump) { + dumpContext.firstDump = false; + return; + } size_t nextDumpLen = 0; size_t dummy = 0; ReturnValue_t result; @@ -2390,7 +2395,7 @@ void CoreController::dirListingDumpHandler() { dumpContext.segmentIdx++; dumpContext.dumpedBytes += nextDumpLen; // Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles. - if (dumpContext.segmentIdx == 25) { + if (dumpContext.segmentIdx == 10) { break; } } diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index a58faf86..05878d6d 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -179,6 +179,7 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe struct DirListingDumpContext { bool active; + bool firstDump; size_t dumpedBytes; size_t totalFileSize; size_t listingDataOffset; diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index 78ba52e4..bd93586c 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -59,6 +59,7 @@ static constexpr uint32_t CFDP_STORE_QUEUE_SIZE = 300; static constexpr uint32_t MAX_PUS_FUNNEL_QUEUE_DEPTH = 100; static constexpr uint32_t MAX_CFDP_FUNNEL_QUEUE_DEPTH = 80; static constexpr uint32_t HK_SERVICE_QUEUE_DEPTH = 60; +static constexpr uint32_t ACTION_SERVICE_QUEUE_DEPTH = 60; static constexpr uint32_t MAX_STORED_CMDS_UDP = 150; static constexpr uint32_t MAX_STORED_CMDS_TCP = 180; diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index 4ec4adec..36c75f0e 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -234,7 +234,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun // PUS service stack new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, config::EIVE_PUS_APID, - pus::PUS_SERVICE_1, objects::PUS_TM_FUNNEL, 40); + pus::PUS_SERVICE_1, objects::PUS_TM_FUNNEL, 120); new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, config::EIVE_PUS_APID, pus::PUS_SERVICE_2, 3, 10); new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, config::EIVE_PUS_APID, @@ -243,7 +243,7 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, config::EIVE_PUS_APID, pus::PUS_SERVICE_5), 80, 160); new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, config::EIVE_PUS_APID, - pus::PUS_SERVICE_8, 16, 60, 50); + pus::PUS_SERVICE_8, config::ACTION_SERVICE_QUEUE_DEPTH, 16, 60); new Service9TimeManagement( PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, config::EIVE_PUS_APID, pus::PUS_SERVICE_9)); From 410fd1c4258b9b50441b2c3de50551fdbeff9663 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 8 Jun 2023 09:11:24 +0200 Subject: [PATCH 147/172] final setting of dec rate filter --- mission/acs/gyroAdisHelpers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/acs/gyroAdisHelpers.h b/mission/acs/gyroAdisHelpers.h index 00fda595..f360db76 100644 --- a/mission/acs/gyroAdisHelpers.h +++ b/mission/acs/gyroAdisHelpers.h @@ -95,7 +95,7 @@ static constexpr uint32_t ADIS_DATASET_ID = READ_SENSOR_DATA; static constexpr uint32_t ADIS_CFG_DATASET_ID = READ_OUT_CONFIG; static constexpr uint16_t FILT_CTRL = 0x0000; -static constexpr uint16_t DEC_RATE = 0x0013; +static constexpr uint16_t DEC_RATE = 0x00C7; enum GlobCmds : uint8_t { FACTORY_CALIBRATION = 0b0000'0010, From cab20a8c77ffee4b827b66ba95b5a58f814d37f3 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 8 Jun 2023 09:55:46 +0200 Subject: [PATCH 148/172] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a779c491..f0bb2574 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ will consitute of a breaking change warranting a new major release: # [v3.0.0] to be released +- eive-fsfw: v3.0.0 + ## Changed - Adapt EM configuration to include all GomSpace PCDU devices except the ACU. For the ACU @@ -63,6 +65,8 @@ will consitute of a breaking change warranting a new major release: - IMTQ HK sets - IMTQ dummy now handles power switch - Added some new ACS parameters +- Enabled decimation filter for the ADIS GYRs +- Enabled second low-pass filter for L3GD20H GYRs ## Fixed From d90ccd62f88c225588e530e3b0e9d321bfa5da47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 12:47:07 +0200 Subject: [PATCH 149/172] bump changelog and tmtc --- CHANGELOG.md | 2 ++ tmtc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17ac5d5d..6a7f07cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ will consitute of a breaking change warranting a new major release: # [v3.0.0] to be released +- `eive-tmtc` version v4.0.0 + ## Changed - Adapt EM configuration to include all GomSpace PCDU devices except the ACU. For the ACU diff --git a/tmtc b/tmtc index 6182369e..8804a4e8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6182369e4f40872c5c26e59be25d5fa79339176a +Subproject commit 8804a4e8e9fce1d45fcf62314affb791114d1517 From 6ef593d8f39a7712c5723b3423e4d46626825992 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:04:16 +0200 Subject: [PATCH 150/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 258f0d33..3a702295 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 258f0d331329d67e13eec9d7f4053fd269e3f9b6 +Subproject commit 3a70229510c017099ff2d43533e19d41f2030d81 From c1f8512b013eb4f5b0946cc49ec993dd5fcceb13 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:10:29 +0200 Subject: [PATCH 151/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2af1ca..937df112 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ will consitute of a breaking change warranting a new major release: only be used to cancel a transfer. - Handling of multiple RWs in the ACS Controller is improved and can be changed by parameter commands. +- Moved PDU `vcc` and `vbat` variable from auxiliary dataset to core dataset. ## Added From 18ba3a711a967ee8b74d9409a56a67fca8709af7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:11:50 +0200 Subject: [PATCH 152/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 3a702295..9a4bf510 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 3a70229510c017099ff2d43533e19d41f2030d81 +Subproject commit 9a4bf5100642301be10689d94ce969d517a6abc4 From 6c1dfafb2eeaa6eecb5b56380b9d5ac6f703fa57 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:13:05 +0200 Subject: [PATCH 153/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2af1ca..b77cb6de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ will consitute of a breaking change warranting a new major release: ## Fixed +- CFDP low level protocol bugfix. Requires `fsfw` update and `tmtc` update. - Compile fix if SCEX is compiled for the EM. - Set up Rad Sensor chip select even for EM to avoid SPI bus issues. - Correct ADIS Gyroscope type configuration for the EM, where the 16507 type is used instead of the From bd7f28152a0f223c58687f30d49d455aff60fa88 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:42:16 +0200 Subject: [PATCH 154/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 9a4bf510..5322de05 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9a4bf5100642301be10689d94ce969d517a6abc4 +Subproject commit 5322de059916efcf874b10ccc766b46e53d2470b From 1453b2abdc88ca8f9dfb7e3278554b14434cbf4d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:48:57 +0200 Subject: [PATCH 155/172] afmt --- mission/controller/acs/ActuatorCmd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/mission/controller/acs/ActuatorCmd.h b/mission/controller/acs/ActuatorCmd.h index 6a1b3dbb..b14a4a25 100644 --- a/mission/controller/acs/ActuatorCmd.h +++ b/mission/controller/acs/ActuatorCmd.h @@ -3,7 +3,6 @@ #include - class ActuatorCmd { public: ActuatorCmd(); From 019d1a7b0d01d4896a4d6236b806ccdbe28e5c1c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 13:51:10 +0200 Subject: [PATCH 156/172] that should do the job --- CMakeLists.txt | 7 +++++++ bsp_q7s/OBSWConfig.h.in | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eaa2d340..8256dc27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,13 @@ else() set(INIT_VAL 1) set(OBSW_STAR_TRACKER_GROUND_CONFIG 0) endif() + +set(OBSW_ADD_TMTC_TCP_SERVER + ${OBSW_Q7S_EM} + CACHE STRING "Add TCP TMTC Server") +set(OBSW_ADD_TMTC_UDP_SERVER + 0 + CACHE STRING "Add UDP TMTC Server") set(OBSW_ADD_MGT ${INIT_VAL} CACHE STRING "Add MGT module") diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index 1c0a4db8..2555d7cd 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -67,8 +67,8 @@ // because UDP packets are not allowed in the VPN // This will cause the OBSW to initialize the TMTC bridge responsible for exchanging data with the // CCSDS IP Cores. -#define OBSW_ADD_TMTC_TCP_SERVER 1 -#define OBSW_ADD_TMTC_UDP_SERVER 1 +#define OBSW_ADD_TMTC_TCP_SERVER @OBSW_ADD_TMTC_TCP_SERVER@ +#define OBSW_ADD_TMTC_UDP_SERVER @OBSW_ADD_TMTC_UDP_SERVER@ // Can be used to switch device to NORMAL mode immediately #define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 0 From fe1cc9444de3c86ffdd9332f5e9ccef49ce6d9a3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 14:10:06 +0200 Subject: [PATCH 157/172] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8321e0f6..e6dfd20f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,8 @@ will consitute of a breaking change warranting a new major release: - Handling of multiple RWs in the ACS Controller is improved and can be changed by parameter commands. - Moved PDU `vcc` and `vbat` variable from auxiliary dataset to core dataset. +- Tweak TCP/IP configuration: Only the TCP server will be included on the EM. For the FM, no + TCP/IP servers will be included by default. ## Added From cd6b7d90be4ece727e21d8792ff6407f8dcec862 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 14:25:59 +0200 Subject: [PATCH 158/172] add one more cfg constant --- common/config/eive/definitions.h | 1 + mission/genericFactory.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index bd93586c..2083962a 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -58,6 +58,7 @@ static constexpr uint32_t CFDP_STORE_QUEUE_SIZE = 300; static constexpr uint32_t MAX_PUS_FUNNEL_QUEUE_DEPTH = 100; static constexpr uint32_t MAX_CFDP_FUNNEL_QUEUE_DEPTH = 80; +static constexpr uint32_t VERIFICATION_SERVICE_QUEUE_DEPTH = 120; static constexpr uint32_t HK_SERVICE_QUEUE_DEPTH = 60; static constexpr uint32_t ACTION_SERVICE_QUEUE_DEPTH = 60; diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index 36c75f0e..466219b3 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -234,7 +234,8 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun // PUS service stack new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, config::EIVE_PUS_APID, - pus::PUS_SERVICE_1, objects::PUS_TM_FUNNEL, 120); + pus::PUS_SERVICE_1, objects::PUS_TM_FUNNEL, + config::VERIFICATION_SERVICE_QUEUE_DEPTH); new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, config::EIVE_PUS_APID, pus::PUS_SERVICE_2, 3, 10); new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, config::EIVE_PUS_APID, From 8e1af9cfba01c146fc1d9699084b03830d649606 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 14:36:10 +0200 Subject: [PATCH 159/172] include stuff --- mission/genericFactory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index 2dd00ee6..bd22dc6b 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -39,6 +39,7 @@ #include #include #include +#include "mission/tmtc/Service15TmStorage.h" #include "OBSWConfig.h" #include "devices/gpioIds.h" @@ -52,13 +53,13 @@ #include "mission/tmtc/tmFilters.h" #include "objects/systemObjectList.h" #include "tmtc/pusIds.h" +#include "devices/gpioIds.h" using persTmStore::PersistentTmStores; #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 // UDP server includes -#include "devices/gpioIds.h" #include "fsfw/osal/common/UdpTcPollingTask.h" #include "fsfw/osal/common/UdpTmTcBridge.h" #endif @@ -66,7 +67,6 @@ using persTmStore::PersistentTmStores; // TCP server includes #include "fsfw/osal/common/TcpTmTcBridge.h" #include "fsfw/osal/common/TcpTmTcServer.h" -#include "mission/tmtc/Service15TmStorage.h" #endif #endif From e13fee75d0e8464649a8e2756441733923e155a2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 14:38:54 +0200 Subject: [PATCH 160/172] this is dumb --- mission/genericFactory.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index bd22dc6b..34c07302 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -39,7 +39,6 @@ #include #include #include -#include "mission/tmtc/Service15TmStorage.h" #include "OBSWConfig.h" #include "devices/gpioIds.h" @@ -50,23 +49,23 @@ #include "mission/system/acs/acsModeTree.h" #include "mission/system/tcs/tcsModeTree.h" #include "mission/tcs/defs.h" +#include "mission/tmtc/Service15TmStorage.h" #include "mission/tmtc/tmFilters.h" #include "objects/systemObjectList.h" #include "tmtc/pusIds.h" -#include "devices/gpioIds.h" using persTmStore::PersistentTmStores; #if OBSW_ADD_TCPIP_SERVERS == 1 #if OBSW_ADD_TMTC_UDP_SERVER == 1 // UDP server includes -#include "fsfw/osal/common/UdpTcPollingTask.h" -#include "fsfw/osal/common/UdpTmTcBridge.h" +#include +#include #endif #if OBSW_ADD_TMTC_TCP_SERVER == 1 // TCP server includes -#include "fsfw/osal/common/TcpTmTcBridge.h" -#include "fsfw/osal/common/TcpTmTcServer.h" +#include +#include #endif #endif From 171d4976c3956a9f4609104086c82db68b33985b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 14:40:47 +0200 Subject: [PATCH 161/172] removing printout --- bsp_q7s/core/CoreController.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 3304fce8..76460aa5 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1080,7 +1080,6 @@ ReturnValue_t CoreController::actionListDirectoryDumpDirectly(ActionId_t actionI std::filesystem::remove(LIST_DIR_DUMP_WORK_FILE, e); return result; } - sif::debug << "dumped segment " << dumpContext.segmentIdx << std::endl; dumpContext.segmentIdx++; dumpContext.dumpedBytes += nextDumpLen; // Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles. @@ -2391,7 +2390,6 @@ void CoreController::dirListingDumpHandler() { actionHelper.finish(false, dumpContext.commander, dumpContext.actionId, result); return; } - sif::debug << "dumped segment " << dumpContext.segmentIdx << std::endl; dumpContext.segmentIdx++; dumpContext.dumpedBytes += nextDumpLen; // Dump takes multiple task cycles, so cache the dump state and continue dump the next cycles. From 9cd38a33d4d997d9d036bc9fff9d10e27e509bc8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 17:16:01 +0200 Subject: [PATCH 162/172] minor tweaks to fix main build --- dummies/helperFactory.h | 2 +- mission/cfdp/CfdpHandler.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dummies/helperFactory.h b/dummies/helperFactory.h index e3809404..e3d2a647 100644 --- a/dummies/helperFactory.h +++ b/dummies/helperFactory.h @@ -19,7 +19,7 @@ struct DummyCfg { bool addTempSensorDummies = true; bool addRtdComIFDummy = true; bool addPlocDummies = true; - bool addCamSwitcherDummy = true; + bool addCamSwitcherDummy = false; }; void createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitch, GpioIF* gpioIF); diff --git a/mission/cfdp/CfdpHandler.cpp b/mission/cfdp/CfdpHandler.cpp index 902097b6..baf501e4 100644 --- a/mission/cfdp/CfdpHandler.cpp +++ b/mission/cfdp/CfdpHandler.cpp @@ -93,6 +93,7 @@ ReturnValue_t CfdpHandler::handleCfdpPacket(TmTcMessage& msg) { return INVALID_PDU_FORMAT; } if (not FileDirectiveReader::checkFileDirective(pduDataField[0])) { + sif::error << "CfdpHandler: Invalid PDU directive field " << pduDataField[0] << std::endl; return INVALID_DIRECTIVE_FIELD; } auto directive = static_cast(pduDataField[0]); From cf48a187335dbccf1e5b962efaa3ae8e563ec39f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 18:12:32 +0200 Subject: [PATCH 163/172] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 9372b2a5..5322de05 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9372b2a575aaa3a2c9e93d6e745a4e3fd08d0004 +Subproject commit 5322de059916efcf874b10ccc766b46e53d2470b From 45b9e88915d8c0efc2b0b281bcddce5b80fe3737 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 18:25:59 +0200 Subject: [PATCH 164/172] route CFDP to live VC0 --- bsp_q7s/em/emObjectFactory.cpp | 1 + bsp_q7s/fmObjectFactory.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 5b2935b7..5270e887 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -140,6 +140,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_TM_TO_PTME == 1 if (ccsdsArgs.liveDestination != nullptr) { pusFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); + cfdpFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); } #endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index df0bbc91..5eeeef59 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -97,6 +97,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_TM_TO_PTME == 1 if (ccsdsArgs.liveDestination != nullptr) { pusFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); + cfdpFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); } #endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ From e3ae6260ad2dea57169a2674953900f16e870d83 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 18:26:41 +0200 Subject: [PATCH 165/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22b62224..25598cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,6 +112,7 @@ will consitute of a breaking change warranting a new major release: - Various fixes for the pointing modes of the `ACS Controller`. All modes should work now as intended. - The variance for the ADIS GYRs now represents the used `-3` version and not the `-1` version +- CFDP funnel did not route packets to live channel VC0 # [v2.0.5] 2023-05-11 From bd2f1bf7f24fb288e138c39c93b34969fb160c2c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 18:25:59 +0200 Subject: [PATCH 166/172] route CFDP to live VC0 --- bsp_q7s/em/emObjectFactory.cpp | 1 + bsp_q7s/fmObjectFactory.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 0311a468..eca9847d 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -140,6 +140,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_TM_TO_PTME == 1 if (ccsdsArgs.liveDestination != nullptr) { pusFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); + cfdpFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); } #endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index df0bbc91..5eeeef59 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -97,6 +97,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_TM_TO_PTME == 1 if (ccsdsArgs.liveDestination != nullptr) { pusFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); + cfdpFunnel->addLiveDestination("VC0 LIVE TM", *ccsdsArgs.liveDestination, 0); } #endif #endif /* OBSW_ADD_CCSDS_IP_CORES == 1 */ From 4146050807668424ef14113baabd9cb6cff865bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 18:26:41 +0200 Subject: [PATCH 167/172] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..43f7afc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. +- CFDP funnel did not route packets to live channel VC0 # [v2.0.5] 2023-05-11 From 7132b0c53f80765044f4a4279ec2507d82233eaf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 9 Jun 2023 19:07:23 +0200 Subject: [PATCH 168/172] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 8804a4e8..a9694816 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 8804a4e8e9fce1d45fcf62314affb791114d1517 +Subproject commit a969481698a205b8ae1d303cbee5bf88eb3defdc From 407901d990bca02fd3fcb7e0a97d11431cecf6a1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 10 Jun 2023 14:48:10 +0200 Subject: [PATCH 169/172] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index a9694816..522f273c 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a969481698a205b8ae1d303cbee5bf88eb3defdc +Subproject commit 522f273c99845f9c50aaf135b1c6f52676b975dd From ef40391c09b4ec0841bbe97189647bde31dde42a Mon Sep 17 00:00:00 2001 From: meggert Date: Sat, 10 Jun 2023 15:34:45 +0200 Subject: [PATCH 170/172] removed debug output --- linux/acs/AcsBoardPolling.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux/acs/AcsBoardPolling.cpp b/linux/acs/AcsBoardPolling.cpp index b8539a8f..1ba55357 100644 --- a/linux/acs/AcsBoardPolling.cpp +++ b/linux/acs/AcsBoardPolling.cpp @@ -572,8 +572,6 @@ void AcsBoardPolling::gyroAdisHandler(GyroAdis& gyro) { return; } uint16_t decRateReadBack = (rawReply[10] << 8) | rawReply[11]; - sif::debug << "AcsPollingTask: DEC rate configuration. Read " << decRateReadBack - << ", expected " << decRate << std::endl; if (decRateReadBack != decRate) { sif::warning << "AcsPollingTask: DEC rate configuration failed. Read " << decRateReadBack << ", expected " << decRate << std::endl; From 3fdd1feb94893f609edca9671151c56d1af42762 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 11 Jun 2023 18:46:30 +0200 Subject: [PATCH 171/172] prep release --- CHANGELOG.md | 2 +- fsfw | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25598cd8..1c450e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ will consitute of a breaking change warranting a new major release: # [v4.0.0] to be released -# [v3.0.0] to be released +# [v3.0.0] 2023-06-11 - `eive-tmtc` version v4.0.0 diff --git a/fsfw b/fsfw index 5322de05..9372b2a5 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 5322de059916efcf874b10ccc766b46e53d2470b +Subproject commit 9372b2a575aaa3a2c9e93d6e745a4e3fd08d0004 From 20e920cde2277d6d43896e674a41666fb8d64454 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 11 Jun 2023 18:49:28 +0200 Subject: [PATCH 172/172] bump fsfw again --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 9372b2a5..5322de05 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9372b2a575aaa3a2c9e93d6e745a4e3fd08d0004 +Subproject commit 5322de059916efcf874b10ccc766b46e53d2470b