From 5879eb7f7b83205c64980580c16d3aa78d6ea073 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 26 Jan 2024 11:06:05 +0100 Subject: [PATCH 01/29] rotation from quaternions --- .../math/QuaternionOperations.cpp | 23 +++++++++++++++++++ .../math/QuaternionOperations.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp index ce44dc08..293eb168 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp @@ -153,3 +153,26 @@ double QuaternionOperations::getAngle(const double* quaternion, bool abs) { } } } + +void QuaternionOperations::rotationFromQuaternions(const double qNew[4], const double qOld[4], + const double timeDelta, + double rotRate[3]) { + double qOldInv[4] = {0, 0, 0, 0}; + double qDelta[4] = {0, 0, 0, 0}; + + inverse(qOld, qOldInv); + multiply(qNew, qOldInv, qDelta); + if (VectorOperations::norm(qDelta, 4) != 0.0) { + normalize(qDelta); + } + if (VectorOperations::norm(qDelta, 3) == 0.0) { + rotRate[0] = 0.0; + rotRate[1] = 0.0; + rotRate[2] = 0.0; + return; + } + double rotVec[3] = {0, 0, 0}; + double angle = getAngle(qDelta); + VectorOperations::normalize(qDelta, rotVec, 3); + VectorOperations::mulScalar(rotVec, angle / timeDelta, rotRate, 3); +} diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.h b/src/fsfw/globalfunctions/math/QuaternionOperations.h index 473cee2b..4e302017 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.h +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.h @@ -25,6 +25,9 @@ class QuaternionOperations { static void slerp(const double q1[4], const double q2[4], const double weight, double q[4]); + static void rotationFromQuaternions(const double qNew[4], const double qOld[4], + const double timeDelta, double rotRate[3]); + /** * returns angle in ]-Pi;Pi] or [0;Pi] if abs == true */ From d5a52eadbb85269fccb4f29acc1aa18582876aac Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 12 Feb 2024 14:20:04 +0100 Subject: [PATCH 02/29] i should have done this ages ago --- .../coordinates/CoordinateTransformations.cpp | 59 ++++++++ .../coordinates/CoordinateTransformations.h | 6 + .../globalfunctions/math/MatrixOperations.h | 136 ++++++++++++++++++ .../globalfunctions/math/VectorOperations.h | 9 ++ 4 files changed, 210 insertions(+) diff --git a/src/fsfw/coordinates/CoordinateTransformations.cpp b/src/fsfw/coordinates/CoordinateTransformations.cpp index 322a7f0d..a983d0a2 100644 --- a/src/fsfw/coordinates/CoordinateTransformations.cpp +++ b/src/fsfw/coordinates/CoordinateTransformations.cpp @@ -6,6 +6,7 @@ #include "fsfw/globalfunctions/constants.h" #include "fsfw/globalfunctions/math/MatrixOperations.h" #include "fsfw/globalfunctions/math/VectorOperations.h" +#include "fsfw/globalfunctions/sign.h" void CoordinateTransformations::positionEcfToEci(const double* ecfPosition, double* eciPosition, timeval* timeUTC) { @@ -207,3 +208,61 @@ void CoordinateTransformations::getTransMatrixECITOECF(timeval timeUTC, double T MatrixOperations::multiply(mTheta[0], Ttemp[0], Tfi[0], 3, 3, 3); }; + +void CoordinateTransformations::cartesianFromLatLongAlt(const double lat, const double longi, + const double alt, double* cartesianOutput) { + /* @brief: cartesianFromLatLongAlt() - calculates cartesian coordinates in ECEF from latitude, + * longitude and altitude + * @param: lat geodetic latitude [rad] + * longi longitude [rad] + * alt altitude [m] + * cartesianOutput Cartesian Coordinates in ECEF (3x1) + * @source: Fundamentals of Spacecraft Attitude Determination and Control, P.34ff + * Landis Markley and John L. Crassidis*/ + double radiusPolar = 6356752.314; + double radiusEqua = 6378137; + + double eccentricity = sqrt(1 - pow(radiusPolar, 2) / pow(radiusEqua, 2)); + double auxRadius = radiusEqua / sqrt(1 - pow(eccentricity, 2) * pow(sin(lat), 2)); + + cartesianOutput[0] = (auxRadius + alt) * cos(lat) * cos(longi); + cartesianOutput[1] = (auxRadius + alt) * cos(lat) * sin(longi); + cartesianOutput[2] = ((1 - pow(eccentricity, 2)) * auxRadius + alt) * sin(lat); +}; + +void CoordinateTransformations::latLongAltFromCartesian(const double* vector, double& latitude, + double& longitude, double& altitude) { + /* @brief: latLongAltFromCartesian() - calculates latitude, longitude and altitude from + * cartesian coordinates in ECEF + * @param: x x-value of position vector [m] + * y y-value of position vector [m] + * z z-value of position vector [m] + * latitude geodetic latitude [rad] + * longitude longitude [rad] + * altitude altitude [m] + * @source: Fundamentals of Spacecraft Attitude Determination and Control, P.35 f + * Landis Markley and John L. Crassidis*/ + // From World Geodetic System the Earth Radii + double a = 6378137.0; // semimajor axis [m] + double b = 6356752.3142; // semiminor axis [m] + + // Calculation + double e2 = 1 - pow(b, 2) / pow(a, 2); + double epsilon2 = pow(a, 2) / pow(b, 2) - 1; + double rho = sqrt(pow(vector[0], 2) + pow(vector[1], 2)); + double p = std::abs(vector[2]) / epsilon2; + double s = pow(rho, 2) / (e2 * epsilon2); + double q = pow(p, 2) - pow(b, 2) + s; + double u = p / sqrt(q); + double v = pow(b, 2) * pow(u, 2) / q; + double P = 27 * v * s / q; + double Q = pow(sqrt(P + 1) + sqrt(P), 2. / 3.); + double t = (1 + Q + 1 / Q) / 6; + double c = sqrt(pow(u, 2) - 1 + 2 * t); + double w = (c - u) / 2; + double d = sign(vector[2]) * sqrt(q) * (w + sqrt(sqrt(pow(t, 2) + v) - u * w - t / 2 - 1. / 4.)); + double N = a * sqrt(1 + epsilon2 * pow(d, 2) / pow(b, 2)); + latitude = asin((epsilon2 + 1) * d / N); + altitude = rho * cos(latitude) + vector[2] * sin(latitude) - pow(a, 2) / N; + longitude = atan2(vector[1], vector[0]); +} diff --git a/src/fsfw/coordinates/CoordinateTransformations.h b/src/fsfw/coordinates/CoordinateTransformations.h index d3760388..60dc2ab1 100644 --- a/src/fsfw/coordinates/CoordinateTransformations.h +++ b/src/fsfw/coordinates/CoordinateTransformations.h @@ -23,6 +23,12 @@ class CoordinateTransformations { static void getEarthRotationMatrix(timeval timeUTC, double matrix[][3]); + static void cartesianFromLatLongAlt(const double lat, const double longi, const double alt, + double* cartesianOutput); + + static void latLongAltFromCartesian(const double* vector, double& latitude, double& longitude, + double& altitude); + private: CoordinateTransformations(); static void ecfToEci(const double* ecfCoordinates, double* eciCoordinates, diff --git a/src/fsfw/globalfunctions/math/MatrixOperations.h b/src/fsfw/globalfunctions/math/MatrixOperations.h index 31966f8f..89c99862 100644 --- a/src/fsfw/globalfunctions/math/MatrixOperations.h +++ b/src/fsfw/globalfunctions/math/MatrixOperations.h @@ -4,6 +4,7 @@ #include #include +#include template class MatrixOperations { @@ -95,6 +96,141 @@ class MatrixOperations { } } } + + static bool isFinite(const T1 *inputMatrix, uint8_t rows, uint8_t cols) { + for (uint8_t col = 0; col < cols; col++) { + for (uint8_t row = 0; row < rows; row++) { + if (not isfinite(inputMatrix[row * cols + cols])) { + return false; + } + } + } + return true; + } + + static void writeSubmatrix(T1 *mainMatrix, T1 *subMatrix, uint8_t subRows, uint8_t subCols, + uint8_t mainRows, uint8_t mainCols, uint8_t startRow, + uint8_t startCol) { + if ((startRow + subRows > mainRows) or (startCol + subCols > mainCols)) { + return; + } + for (uint8_t row = 0; row < subRows; row++) { + for (uint8_t col = 0; col < subCols; col++) { + mainMatrix[(startRow + row) * mainCols + (startCol + col)] = subMatrix[row * subCols + col]; + } + } + } + + static ReturnValue_t inverseMatrix(const T1 *inputMatrix, T1 *inverse, uint8_t size) { + // Stopwatch stopwatch; + T1 matrix[size][size], identity[size][size]; + // reformat array to matrix + for (uint8_t row = 0; row < size; row++) { + for (uint8_t col = 0; col < size; col++) { + matrix[row][col] = inputMatrix[row * size + col]; + } + } + // init identity matrix + std::memset(identity, 0.0, sizeof(identity)); + for (uint8_t diag = 0; diag < size; diag++) { + identity[diag][diag] = 1; + } + // gauss-jordan algo + // sort matrix such as no diag entry shall be 0 + for (uint8_t row = 0; row < size; row++) { + if (matrix[row][row] == 0.0) { + bool swaped = false; + uint8_t rowIndex = 0; + while ((rowIndex < size) && !swaped) { + if ((matrix[rowIndex][row] != 0.0) && (matrix[row][rowIndex] != 0.0)) { + for (uint8_t colIndex = 0; colIndex < size; colIndex++) { + std::swap(matrix[row][colIndex], matrix[rowIndex][colIndex]); + std::swap(identity[row][colIndex], identity[rowIndex][colIndex]); + } + swaped = true; + } + rowIndex++; + } + if (!swaped) { + return returnvalue::FAILED; // matrix not invertible + } + } + } + + for (int row = 0; row < size; row++) { + if (matrix[row][row] == 0.0) { + uint8_t rowIndex; + if (row == 0) { + rowIndex = size - 1; + } else { + rowIndex = row - 1; + } + for (uint8_t colIndex = 0; colIndex < size; colIndex++) { + std::swap(matrix[row][colIndex], matrix[rowIndex][colIndex]); + std::swap(identity[row][colIndex], identity[rowIndex][colIndex]); + } + row--; + if (row < 0) { + return returnvalue::FAILED; // Matrix is not invertible + } + } + } + // remove non diag elements in matrix (jordan) + for (int row = 0; row < size; row++) { + for (int rowIndex = 0; rowIndex < size; rowIndex++) { + if (row != rowIndex) { + double ratio = matrix[rowIndex][row] / matrix[row][row]; + for (int colIndex = 0; colIndex < size; colIndex++) { + matrix[rowIndex][colIndex] -= ratio * matrix[row][colIndex]; + identity[rowIndex][colIndex] -= ratio * identity[row][colIndex]; + } + } + } + } + // normalize rows in matrix (gauss) + for (int row = 0; row < size; row++) { + for (int col = 0; col < size; col++) { + identity[row][col] = identity[row][col] / matrix[row][row]; + } + } + std::memcpy(inverse, identity, sizeof(identity)); + return returnvalue::OK; // successful inversion + } + + static void inverseMatrixDimThree(const T1 *matrix, T1 *output) { + int i, j; + double determinant = 0; + double mat[3][3] = {{matrix[0], matrix[1], matrix[2]}, + {matrix[3], matrix[4], matrix[5]}, + {matrix[6], matrix[7], matrix[8]}}; + + for (i = 0; i < 3; i++) { + determinant = determinant + (mat[0][i] * (mat[1][(i + 1) % 3] * mat[2][(i + 2) % 3] - + mat[1][(i + 2) % 3] * mat[2][(i + 1) % 3])); + } + // cout<<"\n\ndeterminant: "< Date: Mon, 12 Feb 2024 14:36:14 +0100 Subject: [PATCH 03/29] fixes --- src/fsfw/globalfunctions/math/MatrixOperations.h | 4 +++- src/fsfw/globalfunctions/math/VectorOperations.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fsfw/globalfunctions/math/MatrixOperations.h b/src/fsfw/globalfunctions/math/MatrixOperations.h index 89c99862..8d08ed90 100644 --- a/src/fsfw/globalfunctions/math/MatrixOperations.h +++ b/src/fsfw/globalfunctions/math/MatrixOperations.h @@ -1,9 +1,11 @@ #ifndef MATRIXOPERATIONS_H_ #define MATRIXOPERATIONS_H_ +#include #include #include +#include #include template @@ -100,7 +102,7 @@ class MatrixOperations { static bool isFinite(const T1 *inputMatrix, uint8_t rows, uint8_t cols) { for (uint8_t col = 0; col < cols; col++) { for (uint8_t row = 0; row < rows; row++) { - if (not isfinite(inputMatrix[row * cols + cols])) { + if (not std::isfinite(inputMatrix[row * cols + cols])) { return false; } } diff --git a/src/fsfw/globalfunctions/math/VectorOperations.h b/src/fsfw/globalfunctions/math/VectorOperations.h index 6ea21db0..ca82c7f3 100644 --- a/src/fsfw/globalfunctions/math/VectorOperations.h +++ b/src/fsfw/globalfunctions/math/VectorOperations.h @@ -101,7 +101,7 @@ class VectorOperations { static bool isFinite(const T *inputVector, uint8_t size) { for (uint8_t i = 0; i < size; i++) { - if (not isfinite(inputVector[i])) { + if (not std::isfinite(inputVector[i])) { return false; } } From 9894935e9938a753cc9fcd0b00b78de0fd478985 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 12 Feb 2024 14:42:58 +0100 Subject: [PATCH 04/29] time systems --- src/fsfw/globalfunctions/timeSystems.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/fsfw/globalfunctions/timeSystems.h diff --git a/src/fsfw/globalfunctions/timeSystems.h b/src/fsfw/globalfunctions/timeSystems.h new file mode 100644 index 00000000..bb03ebd3 --- /dev/null +++ b/src/fsfw/globalfunctions/timeSystems.h @@ -0,0 +1,20 @@ +#ifndef FSFW_SRC_FSFW_GLOBALFUNCTIONS_TIMESYSTEMS_H_ +#define FSFW_SRC_FSFW_GLOBALFUNCTIONS_TIMESYSTEMS_H_ + +#ifdef PLATFORM_WIN +#include +#else +#include +#endif + +class TimeSystems { + public: + virtual ~TimeSystems() {} + + static double convertUnixToJD2000(timeval time) { + // time = {{s},{us}} + return (time.tv_sec / 86400.0) + 2440587.5 - 2451545; + } +}; + +#endif /* FSFW_SRC_FSFW_GLOBALFUNCTIONS_TIMESYSTEMS_H_ */ From 90f3f8ef1f67dc6d07c242b68bc59c805bb407dd Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 12 Feb 2024 14:51:54 +0100 Subject: [PATCH 05/29] removed printout --- src/fsfw/globalfunctions/math/MatrixOperations.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/fsfw/globalfunctions/math/MatrixOperations.h b/src/fsfw/globalfunctions/math/MatrixOperations.h index 8d08ed90..eefce646 100644 --- a/src/fsfw/globalfunctions/math/MatrixOperations.h +++ b/src/fsfw/globalfunctions/math/MatrixOperations.h @@ -210,8 +210,6 @@ class MatrixOperations { determinant = determinant + (mat[0][i] * (mat[1][(i + 1) % 3] * mat[2][(i + 2) % 3] - mat[1][(i + 2) % 3] * mat[2][(i + 1) % 3])); } - // cout<<"\n\ndeterminant: "< Date: Tue, 13 Feb 2024 15:57:43 +0100 Subject: [PATCH 06/29] Increase configurability of PusServiceBase --- CHANGELOG.md | 2 ++ .../math/QuaternionOperations.cpp | 3 +-- .../math/QuaternionOperations.h | 2 +- .../pus/Service11TelecommandScheduling.tpp | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 4 ++-- src/fsfw/tmtcservices/PusServiceBase.h | 19 +++++++++++-------- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f5bb9bb..024903aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Assert that `FixedArrayList` is larger than 0 at compile time. https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/740 - Health functions are virtual now. +- PUS Service Base request queue depth and maximum number of handled packets per cycle is now + configurable. # [v6.0.0] 2023-02-10 diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp index 293eb168..780a629f 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp @@ -155,8 +155,7 @@ double QuaternionOperations::getAngle(const double* quaternion, bool abs) { } void QuaternionOperations::rotationFromQuaternions(const double qNew[4], const double qOld[4], - const double timeDelta, - double rotRate[3]) { + const double timeDelta, double rotRate[3]) { double qOldInv[4] = {0, 0, 0, 0}; double qDelta[4] = {0, 0, 0, 0}; diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.h b/src/fsfw/globalfunctions/math/QuaternionOperations.h index 4e302017..2ad842be 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.h +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.h @@ -26,7 +26,7 @@ class QuaternionOperations { static void slerp(const double q1[4], const double q2[4], const double weight, double q[4]); static void rotationFromQuaternions(const double qNew[4], const double qOld[4], - const double timeDelta, double rotRate[3]); + const double timeDelta, double rotRate[3]); /** * returns angle in ]-Pi;Pi] or [0;Pi] if abs == true diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index 21852b63..38f6c501 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -150,7 +150,7 @@ inline ReturnValue_t Service11TelecommandScheduling::handleResetCom template inline ReturnValue_t Service11TelecommandScheduling::doInsertActivity( const uint8_t *data, size_t size) { - if(telecommandMap.full()) { + if (telecommandMap.full()) { return MAP_IS_FULL; } uint32_t timestamp = 0; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index fbabbd70..a82a6f97 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -40,7 +40,7 @@ void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle_) { this->taskHandle = void PusServiceBase::handleRequestQueue() { TmTcMessage message; ReturnValue_t result; - for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { + for (uint8_t count = 0; count < psbParams.maxPacketsPerCycle; count++) { ReturnValue_t status = psbParams.reqQueue->receiveMessage(&message); if (status == MessageQueueIF::EMPTY) { break; @@ -98,7 +98,7 @@ ReturnValue_t PusServiceBase::initialize() { } if (psbParams.reqQueue == nullptr) { ownedQueue = true; - psbParams.reqQueue = QueueFactory::instance()->createMessageQueue(PSB_DEFAULT_QUEUE_DEPTH); + psbParams.reqQueue = QueueFactory::instance()->createMessageQueue(psbParams.requestQueueDepth); } else { ownedQueue = false; } diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 92ce0d99..ed48995e 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -20,6 +20,14 @@ class StorageManagerIF; * Configuration parameters for the PUS Service Base */ struct PsbParams { + static constexpr uint8_t PSB_DEFAULT_QUEUE_DEPTH = 10; + /** + * This constant sets the maximum number of packets accepted per call. + * Remember that one packet must be completely handled in one + * #handleRequest call. + */ + static constexpr uint8_t MAX_PACKETS_PER_CYCLE = 10; + PsbParams() = default; PsbParams(uint16_t apid, AcceptsTelemetryIF* tmReceiver) : apid(apid), tmReceiver(tmReceiver) {} PsbParams(const char* name, uint16_t apid, AcceptsTelemetryIF* tmReceiver) @@ -32,6 +40,9 @@ struct PsbParams { object_id_t objectId = objects::NO_OBJECT; uint16_t apid = 0; uint8_t serviceId = 0; + uint32_t requestQueueDepth = PSB_DEFAULT_QUEUE_DEPTH; + uint32_t maxPacketsPerCycle = MAX_PACKETS_PER_CYCLE; + /** * The default destination ID for generated telemetry. If this is not set, @initialize of PSB * will attempt to find a suitable object with the object ID @PusServiceBase::packetDestination @@ -100,14 +111,6 @@ class PusServiceBase : public ExecutableObjectIF, friend void Factory::setStaticFrameworkObjectIds(); public: - /** - * This constant sets the maximum number of packets accepted per call. - * Remember that one packet must be completely handled in one - * #handleRequest call. - */ - static constexpr uint8_t PUS_SERVICE_MAX_RECEPTION = 10; - static constexpr uint8_t PSB_DEFAULT_QUEUE_DEPTH = 10; - /** * @brief The passed values are set, but inter-object initialization is * done in the initialize method. From 7d4e77843b64e812e537e2abd1213c632b6eeb48 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 23 Feb 2024 11:09:59 +0100 Subject: [PATCH 07/29] frmt --- src/fsfw/globalfunctions/math/QuaternionOperations.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp index 293eb168..780a629f 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp @@ -155,8 +155,7 @@ double QuaternionOperations::getAngle(const double* quaternion, bool abs) { } void QuaternionOperations::rotationFromQuaternions(const double qNew[4], const double qOld[4], - const double timeDelta, - double rotRate[3]) { + const double timeDelta, double rotRate[3]) { double qOldInv[4] = {0, 0, 0, 0}; double qDelta[4] = {0, 0, 0, 0}; From bccaf4a9ea2e9d81852a4d3a2c1bd446efc593b6 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 23 Feb 2024 11:31:11 +0100 Subject: [PATCH 08/29] capital --- src/fsfw/globalfunctions/{timeSystems.h => TimeSystems.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/fsfw/globalfunctions/{timeSystems.h => TimeSystems.h} (100%) diff --git a/src/fsfw/globalfunctions/timeSystems.h b/src/fsfw/globalfunctions/TimeSystems.h similarity index 100% rename from src/fsfw/globalfunctions/timeSystems.h rename to src/fsfw/globalfunctions/TimeSystems.h From b2576d34225f2cdb4cf89788bbd254d470ad6c20 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 23 Feb 2024 11:33:20 +0100 Subject: [PATCH 09/29] why are we ignoring usec --- src/fsfw/globalfunctions/TimeSystems.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/globalfunctions/TimeSystems.h b/src/fsfw/globalfunctions/TimeSystems.h index bb03ebd3..533dc5cb 100644 --- a/src/fsfw/globalfunctions/TimeSystems.h +++ b/src/fsfw/globalfunctions/TimeSystems.h @@ -12,8 +12,7 @@ class TimeSystems { virtual ~TimeSystems() {} static double convertUnixToJD2000(timeval time) { - // time = {{s},{us}} - return (time.tv_sec / 86400.0) + 2440587.5 - 2451545; + return ((time.tv_sec + time.tv_usec * 1e-6) / 86400.0) + 2440587.5 - 2451545; } }; From 518a07d05b09b0cebe0d68628757266ce5facc4c Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 5 Mar 2024 14:29:47 +0100 Subject: [PATCH 10/29] removed duplicate code --- src/fsfw/globalfunctions/TimeSystems.h | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 src/fsfw/globalfunctions/TimeSystems.h diff --git a/src/fsfw/globalfunctions/TimeSystems.h b/src/fsfw/globalfunctions/TimeSystems.h deleted file mode 100644 index 533dc5cb..00000000 --- a/src/fsfw/globalfunctions/TimeSystems.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FSFW_SRC_FSFW_GLOBALFUNCTIONS_TIMESYSTEMS_H_ -#define FSFW_SRC_FSFW_GLOBALFUNCTIONS_TIMESYSTEMS_H_ - -#ifdef PLATFORM_WIN -#include -#else -#include -#endif - -class TimeSystems { - public: - virtual ~TimeSystems() {} - - static double convertUnixToJD2000(timeval time) { - return ((time.tv_sec + time.tv_usec * 1e-6) / 86400.0) + 2440587.5 - 2451545; - } -}; - -#endif /* FSFW_SRC_FSFW_GLOBALFUNCTIONS_TIMESYSTEMS_H_ */ From 26730702045f24ca23e15d3db1148ab1f3ce47d9 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 6 Mar 2024 09:41:02 +0100 Subject: [PATCH 11/29] actually do something with this rtval --- src/fsfw/coordinates/CoordinateTransformations.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fsfw/coordinates/CoordinateTransformations.cpp b/src/fsfw/coordinates/CoordinateTransformations.cpp index a983d0a2..60dc4301 100644 --- a/src/fsfw/coordinates/CoordinateTransformations.cpp +++ b/src/fsfw/coordinates/CoordinateTransformations.cpp @@ -7,6 +7,7 @@ #include "fsfw/globalfunctions/math/MatrixOperations.h" #include "fsfw/globalfunctions/math/VectorOperations.h" #include "fsfw/globalfunctions/sign.h" +#include "fsfw/serviceinterface.h" void CoordinateTransformations::positionEcfToEci(const double* ecfPosition, double* eciPosition, timeval* timeUTC) { @@ -98,7 +99,14 @@ void CoordinateTransformations::ecfToEci(const double* ecfCoordinates, double* e double CoordinateTransformations::getJuleanCenturiesTT(timeval timeUTC) { timeval timeTT; - Clock::convertUTCToTT(timeUTC, &timeTT); + ReturnValue_t result = Clock::convertUTCToTT(timeUTC, &timeTT); + if (result != returnvalue::OK) { + // i think it is better to continue here than to abort + timeTT = timeUTC; + sif::error << "CoordinateTransformations::Conversion from UTC to TT failed. Continuing " + "calculations with UTC." + << std::endl; + } double jD2000TT; Clock::convertTimevalToJD2000(timeTT, &jD2000TT); From 27c8a97d45ca631fade540daf30b3645a36a003e Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 13 Mar 2024 16:59:14 +0100 Subject: [PATCH 12/29] added function to prevent quaternion sign jump --- src/fsfw/globalfunctions/math/QuaternionOperations.cpp | 9 +++++++++ src/fsfw/globalfunctions/math/QuaternionOperations.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp index 780a629f..1e5283fe 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.cpp +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.cpp @@ -72,6 +72,15 @@ void QuaternionOperations::slerp(const double q1[4], const double q2[4], const d normalize(q); } +void QuaternionOperations::preventSignJump(double qNew[4], const double qOld[4]) { + double qDiff[4] = {0, 0, 0, 0}, qSum[4] = {0, 0, 0, 0}; + VectorOperations::subtract(qOld, qNew, qDiff, 4); + VectorOperations::add(qOld, qNew, qSum, 4); + if (VectorOperations::norm(qDiff, 4) > VectorOperations::norm(qSum, 4)) { + VectorOperations::mulScalar(qNew, -1, qNew, 4); + } +} + QuaternionOperations::QuaternionOperations() {} void QuaternionOperations::normalize(const double* quaternion, double* unitQuaternion) { diff --git a/src/fsfw/globalfunctions/math/QuaternionOperations.h b/src/fsfw/globalfunctions/math/QuaternionOperations.h index 2ad842be..d6f1c38f 100644 --- a/src/fsfw/globalfunctions/math/QuaternionOperations.h +++ b/src/fsfw/globalfunctions/math/QuaternionOperations.h @@ -28,6 +28,8 @@ class QuaternionOperations { static void rotationFromQuaternions(const double qNew[4], const double qOld[4], const double timeDelta, double rotRate[3]); + static void preventSignJump(double qNew[4], const double qOld[4]); + /** * returns angle in ]-Pi;Pi] or [0;Pi] if abs == true */ From 203c0bac5cd5a1ec3df87a569d769077efc23110 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Apr 2024 12:47:11 +0200 Subject: [PATCH 13/29] re-work some FDIR logic --- .../DeviceHandlerFailureIsolation.cpp | 16 +++++++--------- .../DeviceHandlerFailureIsolation.h | 14 +++++++++++++- src/fsfw/fdir/FailureIsolationBase.cpp | 19 +++++-------------- src/fsfw/fdir/FailureIsolationBase.h | 4 ++-- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index d3e5753f..f27570ce 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -26,6 +26,13 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) if (isFdirInActionOrAreWeFaulty(event)) { return returnvalue::OK; } + // No FDIR reactions if we are in external control by default. If the user commands the device + // manually, this might be related to debugging to testing the device in a low-level way. FDIR + // reactions might get in the way of this process by restarting the device or putting it in + // the faulty state. + if (owner->getHealth() == HasHealthIF::EXTERNAL_CONTROL) { + return returnvalue::OK; + } ReturnValue_t result = returnvalue::FAILED; switch (event->getEvent()) { case HasModesIF::MODE_TRANSITION_FAILED: @@ -186,15 +193,6 @@ void DeviceHandlerFailureIsolation::setFdirState(FDIRState state) { fdirState = state; } -void DeviceHandlerFailureIsolation::triggerEvent(Event event, uint32_t parameter1, - uint32_t parameter2) { - // Do not throw error events if fdirState != none. - // This will still forward MODE and HEALTH INFO events in any case. - if (fdirState == NONE || event::getSeverity(event) == severity::INFO) { - FailureIsolationBase::triggerEvent(event, parameter1, parameter2); - } -} - bool DeviceHandlerFailureIsolation::isFdirActionInProgress() { return (fdirState != NONE); } void DeviceHandlerFailureIsolation::startRecovery(Event reason) { diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h index 4835af99..779b5385 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h @@ -17,7 +17,6 @@ class DeviceHandlerFailureIsolation : public FailureIsolationBase { uint8_t eventQueueDepth = 10); ~DeviceHandlerFailureIsolation(); ReturnValue_t initialize(); - void triggerEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0); bool isFdirActionInProgress(); virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper, @@ -41,6 +40,19 @@ class DeviceHandlerFailureIsolation : public FailureIsolationBase { static const uint32_t DEFAULT_MAX_MISSED_REPLY_COUNT = 5; static const uint32_t DEFAULT_MISSED_REPLY_TIME_MS = 10000; + /** + * This is the default implementation of the eventReceived function. + * + * It will perform recoveries or failures on a pre-defined set of events. If the user wants + * to add handling for custom events, this function should be overriden. + * + * It should be noted that this function will not perform FDIR reactions if the handler is + * faulty or in external control by default. If the user commands the device + * manually, this might be related to debugging to testing the device in a low-level way. FDIR + * reactions might get in the way of this process by restarting the device or putting it in + * the faulty state. If the user still requires FDIR handling in the EXTERNAL_CONTROL case, + * this function should be overriden. + */ virtual ReturnValue_t eventReceived(EventMessage* event); virtual void eventConfirmed(EventMessage* event); void wasParentsFault(EventMessage* event); diff --git a/src/fsfw/fdir/FailureIsolationBase.cpp b/src/fsfw/fdir/FailureIsolationBase.cpp index b6dd3773..cbf2cc06 100644 --- a/src/fsfw/fdir/FailureIsolationBase.cpp +++ b/src/fsfw/fdir/FailureIsolationBase.cpp @@ -148,25 +148,16 @@ void FailureIsolationBase::doConfirmFault(EventMessage* event) { ReturnValue_t FailureIsolationBase::confirmFault(EventMessage* event) { return YOUR_FAULT; } void FailureIsolationBase::triggerEvent(Event event, uint32_t parameter1, uint32_t parameter2) { - // With this mechanism, all events are disabled for a certain device. - // That's not so good for visibility. - if (isFdirDisabledForSeverity(event::getSeverity(event))) { - return; - } + // By default, we trigger all events and also call the handler function to handle FDIR reactions + // which might occur due to these events. This makes all events visible. If the handling of + // FDIR reaction should be disabled, this should be done through dedicated logic inside the + // eventReceived function. EventMessage message(event, ownerId, parameter1, parameter2); EventManagerIF::triggerEvent(&message, eventQueue->getId()); eventReceived(&message); } -bool FailureIsolationBase::isFdirDisabledForSeverity(EventSeverity_t severity) { - if ((owner != NULL) && (severity != severity::INFO)) { - if (owner->getHealth() == HasHealthIF::EXTERNAL_CONTROL) { - // External control disables handling of fault messages. - return true; - } - } - return false; -} +bool FailureIsolationBase::isFdirDisabledForSeverity(EventSeverity_t severity) { return false; } void FailureIsolationBase::throwFdirEvent(Event event, uint32_t parameter1, uint32_t parameter2) { EventMessage message(event, ownerId, parameter1, parameter2); diff --git a/src/fsfw/fdir/FailureIsolationBase.h b/src/fsfw/fdir/FailureIsolationBase.h index 42d82d76..4ae7fb95 100644 --- a/src/fsfw/fdir/FailureIsolationBase.h +++ b/src/fsfw/fdir/FailureIsolationBase.h @@ -44,13 +44,13 @@ class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF { virtual void wasParentsFault(EventMessage* event); virtual ReturnValue_t confirmFault(EventMessage* event); virtual void decrementFaultCounters() = 0; + virtual bool isFdirDisabledForSeverity(EventSeverity_t severity); ReturnValue_t sendConfirmationRequest(EventMessage* event, MessageQueueId_t destination = MessageQueueIF::NO_QUEUE); void throwFdirEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0); private: void doConfirmFault(EventMessage* event); - bool isFdirDisabledForSeverity(EventSeverity_t severity); }; -#endif /* FRAMEWORK_FDIR_FAILUREISOLATIONBASE_H_ */ +#endif /* FRAMEWORK_FDIR From c5159fb64559a69a71470cf921b75b9a0b900ea3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Apr 2024 12:52:32 +0200 Subject: [PATCH 14/29] optimize docs --- src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp | 6 ++---- src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h | 4 ++-- src/fsfw/fdir/FailureIsolationBase.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp index f27570ce..aa897769 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.cpp @@ -26,10 +26,8 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event) if (isFdirInActionOrAreWeFaulty(event)) { return returnvalue::OK; } - // No FDIR reactions if we are in external control by default. If the user commands the device - // manually, this might be related to debugging to testing the device in a low-level way. FDIR - // reactions might get in the way of this process by restarting the device or putting it in - // the faulty state. + // As mentioned in the function documentation, no FDIR reaction are performed when the device + // is in external control. if (owner->getHealth() == HasHealthIF::EXTERNAL_CONTROL) { return returnvalue::OK; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h index 779b5385..3c042caa 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h +++ b/src/fsfw/devicehandlers/DeviceHandlerFailureIsolation.h @@ -46,8 +46,8 @@ class DeviceHandlerFailureIsolation : public FailureIsolationBase { * It will perform recoveries or failures on a pre-defined set of events. If the user wants * to add handling for custom events, this function should be overriden. * - * It should be noted that this function will not perform FDIR reactions if the handler is - * faulty or in external control by default. If the user commands the device + * It should be noted that the default implementation will not perform FDIR reactions if the + * handler is faulty or in external control by default. If the user commands the device * manually, this might be related to debugging to testing the device in a low-level way. FDIR * reactions might get in the way of this process by restarting the device or putting it in * the faulty state. If the user still requires FDIR handling in the EXTERNAL_CONTROL case, diff --git a/src/fsfw/fdir/FailureIsolationBase.h b/src/fsfw/fdir/FailureIsolationBase.h index 4ae7fb95..efabf9cd 100644 --- a/src/fsfw/fdir/FailureIsolationBase.h +++ b/src/fsfw/fdir/FailureIsolationBase.h @@ -53,4 +53,4 @@ class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF { void doConfirmFault(EventMessage* event); }; -#endif /* FRAMEWORK_FDIR +#endif /* FRAMEWORK_FDIR */ From 0cfe559b93a29719e6ef524880cf2f5d95cc3e6e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Apr 2024 16:15:07 +0200 Subject: [PATCH 15/29] implement relative timeshift --- src/fsfw/pus/Service9TimeManagement.cpp | 29 +++++++++++++++++++++++++ src/fsfw/pus/Service9TimeManagement.h | 1 + 2 files changed, 30 insertions(+) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index fb32f60e..cf7458cc 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -4,6 +4,7 @@ #include "fsfw/events/EventManagerIF.h" #include "fsfw/pus/servicepackets/Service9Packets.h" +#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/CCSDSTime.h" @@ -28,6 +29,34 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs); return returnvalue::OK; } + case Subservice::RELATIVE_TIMESHIFT: { + timeval currentTime; + Clock::getClock_timeval(¤tTime); + + if (currentPacket.getUserDataLen() != 8) { + return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA; + } + size_t deserLen = 8; + int64_t timeshiftNanos = 0; + SerializeAdapter::deSerialize(×hiftNanos, currentPacket.getUserData(), &deserLen, + SerializeIF::Endianness::NETWORK); + bool positiveShift = true; + if (timeshiftNanos < 0) { + positiveShift = false; + } + timeval offset{}; + offset.tv_sec = std::abs(timeshiftNanos) / 1000000000; + offset.tv_usec = (std::abs(timeshiftNanos) % 1000000000) / 1000; + + timeval newTime; + if (positiveShift) { + newTime = currentTime + offset; + } else { + newTime = currentTime - offset; + } + Clock::setClock(&newTime); + return returnvalue::OK; + } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 556f3df3..508373ac 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -36,6 +36,7 @@ class Service9TimeManagement : public PusServiceBase { enum Subservice { SET_TIME = 128, //!< [EXPORT] : [COMMAND] Time command in ASCII, CUC or CDS format DUMP_TIME = 129, + RELATIVE_TIMESHIFT = 130, }; }; From 0e2fa8dc83a6bfee7d88de8c9b8b6317fbdb1f6a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Apr 2024 16:19:40 +0200 Subject: [PATCH 16/29] lets not forget error handling --- src/fsfw/pus/Service9TimeManagement.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index cf7458cc..8804fa25 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -23,7 +23,10 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } case Subservice::DUMP_TIME: { timeval newTime; - Clock::getClock_timeval(&newTime); + ReturnValue_t result = Clock::getClock_timeval(&newTime); + if (result != returnvalue::OK) { + return result; + } uint32_t subsecondMs = static_cast(std::floor(static_cast(newTime.tv_usec) / 1000.0)); triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs); @@ -31,15 +34,21 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } case Subservice::RELATIVE_TIMESHIFT: { timeval currentTime; - Clock::getClock_timeval(¤tTime); + ReturnValue_t result = Clock::getClock_timeval(¤tTime); + if (result != returnvalue::OK) { + return result; + } if (currentPacket.getUserDataLen() != 8) { return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA; } size_t deserLen = 8; int64_t timeshiftNanos = 0; - SerializeAdapter::deSerialize(×hiftNanos, currentPacket.getUserData(), &deserLen, - SerializeIF::Endianness::NETWORK); + result = SerializeAdapter::deSerialize(×hiftNanos, currentPacket.getUserData(), + &deserLen, SerializeIF::Endianness::NETWORK); + if (result != returnvalue::OK) { + return result; + } bool positiveShift = true; if (timeshiftNanos < 0) { positiveShift = false; @@ -54,8 +63,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } else { newTime = currentTime - offset; } - Clock::setClock(&newTime); - return returnvalue::OK; + return Clock::setClock(&newTime); } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; From f8e3777c43c3d3a44487d11472294f285958a684 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Apr 2024 16:23:21 +0200 Subject: [PATCH 17/29] more fixes --- src/fsfw/pus/Service9TimeManagement.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 8804fa25..5d8462c6 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -27,9 +27,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { if (result != returnvalue::OK) { return result; } - uint32_t subsecondMs = - static_cast(std::floor(static_cast(newTime.tv_usec) / 1000.0)); - triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs); + triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec); return returnvalue::OK; } case Subservice::RELATIVE_TIMESHIFT: { @@ -63,7 +61,12 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } else { newTime = currentTime - offset; } - return Clock::setClock(&newTime); + result = Clock::setClock(&newTime); + if (result == returnvalue::OK) { + // Report new time as event. + triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec); + } + return result; } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; From aff6bb673bb208ccd764770a3beb91a1250620e0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Apr 2024 10:34:28 +0200 Subject: [PATCH 18/29] make marius the happies man alive --- src/fsfw/pus/Service9TimeManagement.cpp | 4 ++-- src/fsfw/pus/Service9TimeManagement.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 5d8462c6..004cf7d0 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -52,8 +52,8 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { positiveShift = false; } timeval offset{}; - offset.tv_sec = std::abs(timeshiftNanos) / 1000000000; - offset.tv_usec = (std::abs(timeshiftNanos) % 1000000000) / 1000; + offset.tv_sec = std::abs(timeshiftNanos) / NANOS_PER_SECOND; + offset.tv_usec = (std::abs(timeshiftNanos) % NANOS_PER_SECOND) / 1000; timeval newTime; if (positiveShift) { diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 508373ac..4170d615 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -7,9 +7,11 @@ class Service9TimeManagement : public PusServiceBase { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_9; + static constexpr uint32_t NANOS_PER_SECOND= 1'000'000'000; + //!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds. static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO); - //!< Clock dump event. P1: timeval seconds P2: timeval milliseconds. + //!< Clock dump event. P1: timeval seconds P2: timeval microseconds. static constexpr Event CLOCK_DUMP = MAKE_EVENT(1, severity::INFO); //!< Clock could not be set. P1: Returncode. static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW); From 31d4b855236ddd0b85e9e754c842a50c232551eb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Apr 2024 13:14:20 +0200 Subject: [PATCH 19/29] some optimizations --- src/fsfw/pus/Service9TimeManagement.cpp | 33 ++++++++++++++----------- src/fsfw/pus/Service9TimeManagement.h | 6 ++++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 004cf7d0..3a8341d8 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -2,10 +2,9 @@ #include -#include "fsfw/events/EventManagerIF.h" #include "fsfw/pus/servicepackets/Service9Packets.h" +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serialize/SerializeAdapter.h" -#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/CCSDSTime.h" Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) { @@ -19,7 +18,10 @@ ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::SET_TIME: { - return setTime(); + reportCurrentTime(); + ReturnValue_t result = setTime(); + reportCurrentTime(); + return result; } case Subservice::DUMP_TIME: { timeval newTime; @@ -36,6 +38,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { if (result != returnvalue::OK) { return result; } + triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec); if (currentPacket.getUserDataLen() != 8) { return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA; @@ -63,8 +66,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } result = Clock::setClock(&newTime); if (result == returnvalue::OK) { - // Report new time as event. - triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec); + reportTime(newTime); } return result; } @@ -83,17 +85,20 @@ ReturnValue_t Service9TimeManagement::setTime() { return result; } - timeval time; - Clock::getClock_timeval(&time); result = Clock::setClock(&timeToSet); - - if (result == returnvalue::OK) { - timeval newTime; - Clock::getClock_timeval(&newTime); - triggerEvent(CLOCK_SET, time.tv_sec, newTime.tv_sec); - return returnvalue::OK; - } else { + if (result != returnvalue::OK) { triggerEvent(CLOCK_SET_FAILURE, result, 0); return returnvalue::FAILED; } + return result; +} + +void Service9TimeManagement::reportCurrentTime() { + timeval currentTime{}; + Clock::getClock_timeval(¤tTime); + triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec); +} + +void Service9TimeManagement::reportTime(timeval time) { + triggerEvent(CLOCK_DUMP, time.tv_sec, time.tv_usec); } diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 4170d615..33c71e23 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -1,13 +1,14 @@ #ifndef FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_ #define FSFW_PUS_SERVICE9TIMEMANAGEMENT_H_ +#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/tmtcservices/PusServiceBase.h" class Service9TimeManagement : public PusServiceBase { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_9; - static constexpr uint32_t NANOS_PER_SECOND= 1'000'000'000; + static constexpr uint32_t NANOS_PER_SECOND = 1'000'000'000; //!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds. static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO); @@ -32,6 +33,9 @@ class Service9TimeManagement : public PusServiceBase { */ ReturnValue_t handleRequest(uint8_t subservice) override; + void reportCurrentTime(); + void reportTime(timeval time); + virtual ReturnValue_t setTime(); private: From efbcddc2e5e3e5c53675d46b856ca75eb4453741 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Apr 2024 13:26:55 +0200 Subject: [PATCH 20/29] improvements for time service --- CHANGELOG.md | 3 +++ src/fsfw/pus/Service9TimeManagement.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 024903aa..44b0641b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,9 +28,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - add CFDP subsystem ID https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742 - `PusTmZcWriter` now exposes API to set message counter field. +- Relative timeshift in the PUS time service. ## Changed +- The PUS time service now dumps the time before setting a new time and after having set the + time. - HK generation is now countdown based. - Bump ETL version to 20.35.14 https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/748 diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index 3a8341d8..cbc9bd55 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -34,11 +34,11 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } case Subservice::RELATIVE_TIMESHIFT: { timeval currentTime; - ReturnValue_t result = Clock::getClock_timeval(¤tTime); + ReturnValue_t result = Clock::getClock(¤tTime); if (result != returnvalue::OK) { return result; } - triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec); + reportTime(currentTime); if (currentPacket.getUserDataLen() != 8) { return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA; @@ -95,7 +95,7 @@ ReturnValue_t Service9TimeManagement::setTime() { void Service9TimeManagement::reportCurrentTime() { timeval currentTime{}; - Clock::getClock_timeval(¤tTime); + Clock::getClock(¤tTime); triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec); } From e12a8cfa292085c1ec2e1092f02ec5f722bf667d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Apr 2024 13:31:21 +0200 Subject: [PATCH 21/29] make this change downwards compatible --- src/fsfw/pus/Service9TimeManagement.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 33c71e23..87fcab75 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -12,10 +12,12 @@ class Service9TimeManagement : public PusServiceBase { //!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds. static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO); - //!< Clock dump event. P1: timeval seconds P2: timeval microseconds. - static constexpr Event CLOCK_DUMP = MAKE_EVENT(1, severity::INFO); + //!< Clock dump event. P1: timeval seconds P2: timeval milliseconds. + static constexpr Event CLOCK_DUMP_LEGACY = MAKE_EVENT(1, severity::INFO); //!< Clock could not be set. P1: Returncode. static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW); + //!< Clock dump event. P1: timeval seconds P2: timeval microseconds. + static constexpr Event CLOCK_DUMP = MAKE_EVENT(3, severity::INFO); static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9; From 94bd1ba2ab6c16131f8dd39a84568672d809983d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 8 Apr 2024 13:38:14 +0200 Subject: [PATCH 22/29] fix comment blocks --- src/fsfw/pus/Service9TimeManagement.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 87fcab75..75328bf4 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -10,13 +10,13 @@ class Service9TimeManagement : public PusServiceBase { static constexpr uint32_t NANOS_PER_SECOND = 1'000'000'000; - //!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds. + //!< [EXPORT] : [COMMENT] Clock has been set. P1: old timeval seconds. P2: new timeval seconds. static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO); - //!< Clock dump event. P1: timeval seconds P2: timeval milliseconds. + //!< [EXPORT] : [COMMENT] Clock dump event. P1: timeval seconds P2: timeval milliseconds. static constexpr Event CLOCK_DUMP_LEGACY = MAKE_EVENT(1, severity::INFO); - //!< Clock could not be set. P1: Returncode. + //!< [EXPORT] : [COMMENT] Clock could not be set. P1: Returncode. static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW); - //!< Clock dump event. P1: timeval seconds P2: timeval microseconds. + //!< [EXPORT] : [COMMENT] Clock dump event. P1: timeval seconds P2: timeval microseconds. static constexpr Event CLOCK_DUMP = MAKE_EVENT(3, severity::INFO); static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9; From a229748aa4c1ff8e2b9f7e268259b857fb8f9051 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 9 Apr 2024 10:57:00 +0200 Subject: [PATCH 23/29] distinct clock dump events --- src/fsfw/pus/Service9TimeManagement.cpp | 23 +++++++++-------------- src/fsfw/pus/Service9TimeManagement.h | 6 ++++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/fsfw/pus/Service9TimeManagement.cpp b/src/fsfw/pus/Service9TimeManagement.cpp index cbc9bd55..e8e24f42 100644 --- a/src/fsfw/pus/Service9TimeManagement.cpp +++ b/src/fsfw/pus/Service9TimeManagement.cpp @@ -18,18 +18,13 @@ ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { switch (subservice) { case Subservice::SET_TIME: { - reportCurrentTime(); + reportCurrentTime(CLOCK_DUMP_BEFORE_SETTING_TIME); ReturnValue_t result = setTime(); - reportCurrentTime(); + reportCurrentTime(CLOCK_DUMP_AFTER_SETTING_TIME); return result; } case Subservice::DUMP_TIME: { - timeval newTime; - ReturnValue_t result = Clock::getClock_timeval(&newTime); - if (result != returnvalue::OK) { - return result; - } - triggerEvent(CLOCK_DUMP, newTime.tv_sec, newTime.tv_usec); + reportCurrentTime(); return returnvalue::OK; } case Subservice::RELATIVE_TIMESHIFT: { @@ -38,7 +33,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { if (result != returnvalue::OK) { return result; } - reportTime(currentTime); + reportTime(CLOCK_DUMP_BEFORE_SETTING_TIME, currentTime); if (currentPacket.getUserDataLen() != 8) { return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA; @@ -66,7 +61,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) { } result = Clock::setClock(&newTime); if (result == returnvalue::OK) { - reportTime(newTime); + reportTime(CLOCK_DUMP_AFTER_SETTING_TIME, newTime); } return result; } @@ -93,12 +88,12 @@ ReturnValue_t Service9TimeManagement::setTime() { return result; } -void Service9TimeManagement::reportCurrentTime() { +void Service9TimeManagement::reportCurrentTime(Event event) { timeval currentTime{}; Clock::getClock(¤tTime); - triggerEvent(CLOCK_DUMP, currentTime.tv_sec, currentTime.tv_usec); + triggerEvent(event, currentTime.tv_sec, currentTime.tv_usec); } -void Service9TimeManagement::reportTime(timeval time) { - triggerEvent(CLOCK_DUMP, time.tv_sec, time.tv_usec); +void Service9TimeManagement::reportTime(Event event, timeval time) { + triggerEvent(event, time.tv_sec, time.tv_usec); } diff --git a/src/fsfw/pus/Service9TimeManagement.h b/src/fsfw/pus/Service9TimeManagement.h index 75328bf4..502136c2 100644 --- a/src/fsfw/pus/Service9TimeManagement.h +++ b/src/fsfw/pus/Service9TimeManagement.h @@ -18,6 +18,8 @@ class Service9TimeManagement : public PusServiceBase { static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW); //!< [EXPORT] : [COMMENT] Clock dump event. P1: timeval seconds P2: timeval microseconds. static constexpr Event CLOCK_DUMP = MAKE_EVENT(3, severity::INFO); + static constexpr Event CLOCK_DUMP_BEFORE_SETTING_TIME = MAKE_EVENT(4, severity::INFO); + static constexpr Event CLOCK_DUMP_AFTER_SETTING_TIME = MAKE_EVENT(5, severity::INFO); static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_9; @@ -35,8 +37,8 @@ class Service9TimeManagement : public PusServiceBase { */ ReturnValue_t handleRequest(uint8_t subservice) override; - void reportCurrentTime(); - void reportTime(timeval time); + void reportCurrentTime(Event eventType = CLOCK_DUMP); + void reportTime(Event event, timeval time); virtual ReturnValue_t setTime(); From f307a86d9a972d29ee82234a415bf60a7ce4b6bc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 Apr 2024 13:11:51 +0200 Subject: [PATCH 24/29] improve linux interface --- src/fsfw_hal/linux/serial/helper.cpp | 9 ++++----- src/fsfw_hal/linux/serial/helper.h | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fsfw_hal/linux/serial/helper.cpp b/src/fsfw_hal/linux/serial/helper.cpp index c58689c0..af170757 100644 --- a/src/fsfw_hal/linux/serial/helper.cpp +++ b/src/fsfw_hal/linux/serial/helper.cpp @@ -1,8 +1,6 @@ #include #include -#include "fsfw/serviceinterface.h" - void serial::setMode(struct termios& options, UartModes mode) { if (mode == UartModes::NON_CANONICAL) { /* Disable canonical mode */ @@ -153,15 +151,16 @@ int serial::readCountersAndErrors(int serialPort, serial_icounter_struct& icount } void serial::setStopbits(struct termios& options, StopBits bits) { + // Regular case: One stop bit. + options.c_cflag &= ~CSTOPB; if (bits == StopBits::TWO_STOP_BITS) { // Use two stop bits options.c_cflag |= CSTOPB; - } else { - // Clear stop field, only one stop bit used in communication - options.c_cflag &= ~CSTOPB; } } void serial::flushRxBuf(int fd) { tcflush(fd, TCIFLUSH); } void serial::flushTxRxBuf(int fd) { tcflush(fd, TCIOFLUSH); } + +void serial::flushTxBuf(int fd) { tcflush(fd, TCOFLUSH); } diff --git a/src/fsfw_hal/linux/serial/helper.h b/src/fsfw_hal/linux/serial/helper.h index 623612ad..6b93ae91 100644 --- a/src/fsfw_hal/linux/serial/helper.h +++ b/src/fsfw_hal/linux/serial/helper.h @@ -65,6 +65,7 @@ void setParity(struct termios& options, Parity parity); void ignoreCtrlLines(struct termios& options); void flushRxBuf(int fd); +void flushTxBuf(int fd); void flushTxRxBuf(int fd); int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); From b8ae64606061e593c573d94c70de18e99ce2a00a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Apr 2024 13:53:35 +0200 Subject: [PATCH 25/29] this include might be missing --- src/fsfw_hal/linux/serial/helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw_hal/linux/serial/helper.cpp b/src/fsfw_hal/linux/serial/helper.cpp index c58689c0..9bded3fa 100644 --- a/src/fsfw_hal/linux/serial/helper.cpp +++ b/src/fsfw_hal/linux/serial/helper.cpp @@ -1,6 +1,6 @@ #include #include - +#include "FSFWConfig.h" #include "fsfw/serviceinterface.h" void serial::setMode(struct termios& options, UartModes mode) { From fb2e480705368f2ece8458d40162d23b31c26268 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 16 Apr 2024 13:58:10 +0200 Subject: [PATCH 26/29] did i forgot to push? --- src/fsfw_hal/linux/serial/helper.cpp | 4 ++++ src/fsfw_hal/linux/serial/helper.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/fsfw_hal/linux/serial/helper.cpp b/src/fsfw_hal/linux/serial/helper.cpp index 9bded3fa..6cf86d95 100644 --- a/src/fsfw_hal/linux/serial/helper.cpp +++ b/src/fsfw_hal/linux/serial/helper.cpp @@ -1,5 +1,7 @@ #include #include +#include + #include "FSFWConfig.h" #include "fsfw/serviceinterface.h" @@ -164,4 +166,6 @@ void serial::setStopbits(struct termios& options, StopBits bits) { void serial::flushRxBuf(int fd) { tcflush(fd, TCIFLUSH); } +void serial::flushTxBuf(int fd) { tcflush(fd, TCOFLUSH); } + void serial::flushTxRxBuf(int fd) { tcflush(fd, TCIOFLUSH); } diff --git a/src/fsfw_hal/linux/serial/helper.h b/src/fsfw_hal/linux/serial/helper.h index 623612ad..6b93ae91 100644 --- a/src/fsfw_hal/linux/serial/helper.h +++ b/src/fsfw_hal/linux/serial/helper.h @@ -65,6 +65,7 @@ void setParity(struct termios& options, Parity parity); void ignoreCtrlLines(struct termios& options); void flushRxBuf(int fd); +void flushTxBuf(int fd); void flushTxRxBuf(int fd); int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); From 3b0ee7ca3121a8d9e3e4d10a0c301ef5d1755102 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Apr 2024 10:07:09 +0200 Subject: [PATCH 27/29] i forgot to push.. --- src/fsfw_hal/linux/serial/helper.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fsfw_hal/linux/serial/helper.cpp b/src/fsfw_hal/linux/serial/helper.cpp index af170757..3a0dbb7a 100644 --- a/src/fsfw_hal/linux/serial/helper.cpp +++ b/src/fsfw_hal/linux/serial/helper.cpp @@ -1,5 +1,9 @@ #include #include +#include + +#include "FSFWConfig.h" +#include "fsfw/serviceinterface.h" void serial::setMode(struct termios& options, UartModes mode) { if (mode == UartModes::NON_CANONICAL) { @@ -106,7 +110,7 @@ void serial::setBaudrate(struct termios& options, UartBaudRate baud) { #endif // ! __APPLE__ default: #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl; + sif::warning << "serial::configureBaudrate: Baudrate not supported" << std::endl; #endif break; } @@ -161,6 +165,7 @@ void serial::setStopbits(struct termios& options, StopBits bits) { void serial::flushRxBuf(int fd) { tcflush(fd, TCIFLUSH); } +void serial::flushTxBuf(int fd) { tcflush(fd, TCOFLUSH); } + void serial::flushTxRxBuf(int fd) { tcflush(fd, TCIOFLUSH); } -void serial::flushTxBuf(int fd) { tcflush(fd, TCOFLUSH); } From 7c9b9e4cd8ee521da053688ec06bd1b8b93fe3a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Apr 2024 12:08:08 +0200 Subject: [PATCH 28/29] initialize FDIR component properly --- src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp b/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp index 2b4ab27b..1b463a37 100644 --- a/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp @@ -11,6 +11,7 @@ FreshDeviceHandlerBase::FreshDeviceHandlerBase(DhbConfig config) healthHelper(this, getObjectId()), paramHelper(this), poolManager(this, nullptr), + fdirInstance(config.fdirInstance), defaultFdirParent(config.defaultFdirParent) { auto mqArgs = MqArgs(config.objectId, static_cast(this)); messageQueue = QueueFactory::instance()->createMessageQueue( From 0660457c92b4bc5a533e0821752b21c485e75fc7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 17 Apr 2024 12:11:07 +0200 Subject: [PATCH 29/29] check for FDIR failures --- src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp | 1 + src/fsfw/devicehandlers/FreshDeviceHandlerBase.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp b/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp index 1b463a37..1aa4431c 100644 --- a/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/FreshDeviceHandlerBase.cpp @@ -31,6 +31,7 @@ FreshDeviceHandlerBase::~FreshDeviceHandlerBase() { ReturnValue_t FreshDeviceHandlerBase::performOperation(uint8_t opCode) { performDeviceOperationPreQueueHandling(opCode); handleQueue(); + fdirInstance->checkForFailures(); performDeviceOperation(opCode); poolManager.performHkOperation(); return returnvalue::OK; diff --git a/src/fsfw/devicehandlers/FreshDeviceHandlerBase.h b/src/fsfw/devicehandlers/FreshDeviceHandlerBase.h index c911c1dd..8f2dd24f 100644 --- a/src/fsfw/devicehandlers/FreshDeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/FreshDeviceHandlerBase.h @@ -129,7 +129,7 @@ class FreshDeviceHandlerBase : public SystemObject, ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) override = 0; // Executable overrides. - ReturnValue_t performOperation(uint8_t opCode) override; + virtual ReturnValue_t performOperation(uint8_t opCode) override; ReturnValue_t initializeAfterTaskCreation() override; /**