Compare commits

..

1 Commits

Author SHA1 Message Date
b03e53b6e9 Re-work MPSoC handler module
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2024-04-25 17:31:41 +02:00
24 changed files with 263 additions and 469 deletions

View File

@@ -16,18 +16,9 @@ will consitute of a breaking change warranting a new major release:
# [unreleased] # [unreleased]
# [v8.0.0] 2024-05-13
- `eive-tmtc` v7.0.0
## Fixed
- Fixed calculation for target rotation rate during pointing modes.
- Possible fix for MPSoC file read algorithm.
## Changed ## Changed
- Reworked MPSoC handler to be compatible to new MPSoC software image and use - Reworked MPSoC handler to be compatible to new MPSoC software image and use
new device handler base class. This should increase the reliability of the communication new device handler base class. This should increase the reliability of the communication
significantly. significantly.
- MPSoC device modes IDLE, SNAPSHOT and REPLAY are now modelled using submodes. - MPSoC device modes IDLE, SNAPSHOT and REPLAY are now modelled using submodes.
@@ -41,8 +32,6 @@ will consitute of a breaking change warranting a new major release:
# [v7.8.1] 2024-04-11 # [v7.8.1] 2024-04-11
## Fixed
- Reverted fix for wrong order in quaternion multiplication for computation of the error quaternion. - Reverted fix for wrong order in quaternion multiplication for computation of the error quaternion.
# [v7.8.0] 2024-04-10 # [v7.8.0] 2024-04-10
@@ -53,7 +42,7 @@ will consitute of a breaking change warranting a new major release:
- All pointing laws are now allowed to use the `MEKF` per default. - All pointing laws are now allowed to use the `MEKF` per default.
- Changed limits in `PWR Controller`. - Changed limits in `PWR Controller`.
- PUS time service: Now dumps the time before and after relative timeshift or setting absolute time - PUS time service: Now dumps the time before and after relative timeshift or setting absolute time
- The `GPS Controller` does not set itself to `OFF` anymore, if it has not detected a valid fix for - The `GPS Controller` does not set itself to `OFF` anymore, if it has not detected a valid fix for
some time. Instead it attempts to reset both GNSS devices once. some time. Instead it attempts to reset both GNSS devices once.
- The maximum time to reach a fix is shortened from 30min to 15min. - The maximum time to reach a fix is shortened from 30min to 15min.
- The time the reset pin of the GNSS devices is pulled is prolonged from 5ms to 10s. - The time the reset pin of the GNSS devices is pulled is prolonged from 5ms to 10s.
@@ -62,7 +51,7 @@ will consitute of a breaking change warranting a new major release:
of the controller is changed. As arguments it now displays the new fix and the numer of fix changes of the controller is changed. As arguments it now displays the new fix and the numer of fix changes
missed. missed.
- The number of satellites seen and used is reset to 0, in case they are set to invalid. - The number of satellites seen and used is reset to 0, in case they are set to invalid.
- Altitude, latitude and longitude messages are not checked anymore, in case the mode message was - Altitude, latitude and longitude messages are not checked anymore, in case the mode message was
already invalid. already invalid.
## Added ## Added
@@ -276,7 +265,7 @@ will consitute of a breaking change warranting a new major release:
- `ACS Controller` now has the function `performAttitudeControl` which is called prior to passing - `ACS Controller` now has the function `performAttitudeControl` which is called prior to passing
on to the relevant mode functions. It handles all telemetry relevant functions, which were on to the relevant mode functions. It handles all telemetry relevant functions, which were
always called, regardless of the mode. always called, regardless of the mode.
## Added ## Added
- Higher ACS modes can now be entered without a running `MEKF`. Higher modes will collect their - Higher ACS modes can now be entered without a running `MEKF`. Higher modes will collect their

View File

@@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 325 translations. * @brief Auto-generated event translation file. Contains 324 translations.
* @details * @details
* Generated on: 2024-05-06 13:47:38 * Generated on: 2024-04-17 11:22:10
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@@ -142,7 +142,6 @@ const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUEN
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON"; const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT"; const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT";
const char *CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING = "CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE";
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
@@ -607,8 +606,6 @@ const char *translateEvents(Event event) {
return SUPV_NOT_ON_STRING; return SUPV_NOT_ON_STRING;
case (11608): case (11608):
return SUPV_REPLY_TIMEOUT_STRING; return SUPV_REPLY_TIMEOUT_STRING;
case (11609):
return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING;
case (11701): case (11701):
return SELF_TEST_I2C_FAILURE_STRING; return SELF_TEST_I2C_FAILURE_STRING;
case (11702): case (11702):

View File

@@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 176 translations. * Contains 176 translations.
* Generated on: 2024-05-06 13:47:38 * Generated on: 2024-04-17 11:22:10
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@@ -65,7 +65,6 @@
#include "linux/payload/PlocMpsocSpecialComHelper.h" #include "linux/payload/PlocMpsocSpecialComHelper.h"
#include "linux/payload/SerialConfig.h" #include "linux/payload/SerialConfig.h"
#include "mission/config/configfile.h" #include "mission/config/configfile.h"
#include "mission/power/defs.h"
#include "mission/system/acs/AcsBoardFdir.h" #include "mission/system/acs/AcsBoardFdir.h"
#include "mission/system/acs/AcsSubsystem.h" #include "mission/system/acs/AcsSubsystem.h"
#include "mission/system/acs/RwAssembly.h" #include "mission/system/acs/RwAssembly.h"
@@ -636,9 +635,9 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit
auto specialComHelper = auto specialComHelper =
new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER, *mpsocCommunication); new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER, *mpsocCommunication);
DhbConfig dhbConf(objects::PLOC_MPSOC_HANDLER); DhbConfig dhbConf(objects::PLOC_MPSOC_HANDLER);
auto* mpsocHandler = new FreshMpsocHandler( auto* mpsocHandler = new FreshMpsocHandler(dhbConf, *mpsocCommunication, *specialComHelper,
dhbConf, *mpsocCommunication, *specialComHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF),
objects::PLOC_SUPERVISOR_HANDLER, pwrSwitcher, power::PDU2_CH8_PAYLOAD_CAMERA); objects::PLOC_SUPERVISOR_HANDLER);
mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #endif /* OBSW_ADD_PLOC_MPSOC == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1 #if OBSW_ADD_PLOC_SUPERVISOR == 1

2
fsfw

Submodule fsfw updated: 42867ad0cb...0660457c92

View File

@@ -135,8 +135,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/plocMpsocHelpers.h 11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/plocMpsocHelpers.h
11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/plocMpsocHelpers.h 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/plocMpsocHelpers.h
11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/plocMpsocHelpers.h 11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/plocMpsocHelpers.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;SUPV reply timeout.;linux/payload/plocMpsocHelpers.h 11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/plocMpsocHelpers.h
11609;0x2d59;CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE;LOW;Camera must be commanded on first.;linux/payload/plocMpsocHelpers.h
11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
1 Event ID (dec) Event ID (hex) Name Severity Description File Path
135 11605 0x2d55 MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH LOW Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count linux/payload/plocMpsocHelpers.h
136 11606 0x2d56 MPSOC_SHUTDOWN_FAILED HIGH Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor. linux/payload/plocMpsocHelpers.h
137 11607 0x2d57 SUPV_NOT_ON LOW SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition. linux/payload/plocMpsocHelpers.h
138 11608 0x2d58 SUPV_REPLY_TIMEOUT LOW SUPV reply timeout. No description linux/payload/plocMpsocHelpers.h
11609 0x2d59 CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE LOW Camera must be commanded on first. linux/payload/plocMpsocHelpers.h
139 11701 0x2db5 SELF_TEST_I2C_FAILURE LOW Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
140 11702 0x2db6 SELF_TEST_SPI_FAILURE LOW Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
141 11703 0x2db7 SELF_TEST_ADC_FAILURE LOW Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h

View File

@@ -135,8 +135,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/plocMpsocHelpers.h 11605;0x2d55;MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH;LOW;Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count;linux/payload/plocMpsocHelpers.h
11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/plocMpsocHelpers.h 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/plocMpsocHelpers.h
11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/plocMpsocHelpers.h 11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/plocMpsocHelpers.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;SUPV reply timeout.;linux/payload/plocMpsocHelpers.h 11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/plocMpsocHelpers.h
11609;0x2d59;CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE;LOW;Camera must be commanded on first.;linux/payload/plocMpsocHelpers.h
11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h
1 Event ID (dec) Event ID (hex) Name Severity Description File Path
135 11605 0x2d55 MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH LOW Packet sequence count in received space packet does not match expected count P1: Expected sequence count P2: Received sequence count linux/payload/plocMpsocHelpers.h
136 11606 0x2d56 MPSOC_SHUTDOWN_FAILED HIGH Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor. linux/payload/plocMpsocHelpers.h
137 11607 0x2d57 SUPV_NOT_ON LOW SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition. linux/payload/plocMpsocHelpers.h
138 11608 0x2d58 SUPV_REPLY_TIMEOUT LOW SUPV reply timeout. No description linux/payload/plocMpsocHelpers.h
11609 0x2d59 CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE LOW Camera must be commanded on first. linux/payload/plocMpsocHelpers.h
139 11701 0x2db5 SELF_TEST_I2C_FAILURE LOW Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
140 11702 0x2db6 SELF_TEST_SPI_FAILURE LOW Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h
141 11703 0x2db7 SELF_TEST_ADC_FAILURE LOW Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA mission/acs/ImtqHandler.h

View File

@@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 325 translations. * @brief Auto-generated event translation file. Contains 324 translations.
* @details * @details
* Generated on: 2024-05-06 13:47:38 * Generated on: 2024-04-17 11:22:10
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@@ -142,7 +142,6 @@ const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUEN
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON"; const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT"; const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT";
const char *CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING = "CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE";
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
@@ -607,8 +606,6 @@ const char *translateEvents(Event event) {
return SUPV_NOT_ON_STRING; return SUPV_NOT_ON_STRING;
case (11608): case (11608):
return SUPV_REPLY_TIMEOUT_STRING; return SUPV_REPLY_TIMEOUT_STRING;
case (11609):
return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING;
case (11701): case (11701):
return SELF_TEST_I2C_FAILURE_STRING; return SELF_TEST_I2C_FAILURE_STRING;
case (11702): case (11702):

View File

@@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 180 translations. * Contains 180 translations.
* Generated on: 2024-05-06 13:47:38 * Generated on: 2024-04-17 11:22:10
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 325 translations. * @brief Auto-generated event translation file. Contains 324 translations.
* @details * @details
* Generated on: 2024-05-06 13:47:38 * Generated on: 2024-04-17 11:22:10
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@@ -142,7 +142,6 @@ const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUEN
const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED";
const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON"; const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT"; const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT";
const char *CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING = "CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE";
const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE";
const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE";
const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE";
@@ -607,8 +606,6 @@ const char *translateEvents(Event event) {
return SUPV_NOT_ON_STRING; return SUPV_NOT_ON_STRING;
case (11608): case (11608):
return SUPV_REPLY_TIMEOUT_STRING; return SUPV_REPLY_TIMEOUT_STRING;
case (11609):
return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING;
case (11701): case (11701):
return SELF_TEST_I2C_FAILURE_STRING; return SELF_TEST_I2C_FAILURE_STRING;
case (11702): case (11702):

View File

@@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 180 translations. * Contains 180 translations.
* Generated on: 2024-05-06 13:47:38 * Generated on: 2024-04-17 11:22:10
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@@ -8,29 +8,22 @@
#include "fsfw/devicehandlers/FreshDeviceHandlerBase.h" #include "fsfw/devicehandlers/FreshDeviceHandlerBase.h"
#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/power/PowerSwitchIF.h"
#include "fsfw/power/definitions.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeAdapter.h"
#include "linux/payload/MpsocCommunication.h" #include "linux/payload/MpsocCommunication.h"
#include "linux/payload/plocMpsocHelpers.h" #include "linux/payload/plocMpsocHelpers.h"
#include "linux/payload/plocSupvDefs.h" #include "linux/payload/plocSupvDefs.h"
#include "mission/power/gsDefs.h"
FreshMpsocHandler::FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface, FreshMpsocHandler::FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface,
PlocMpsocSpecialComHelper& specialComHelper, PlocMpsocSpecialComHelper& specialComHelper,
Gpio uartIsolatorSwitch, object_id_t supervisorHandler, Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
PowerSwitchIF& powerSwitcher, power::Switch_t camSwitchId)
: FreshDeviceHandlerBase(cfg), : FreshDeviceHandlerBase(cfg),
comInterface(comInterface), comInterface(comInterface),
specialComHelper(specialComHelper), specialComHelper(specialComHelper),
commandActionHelper(this), commandActionHelper(this),
uartIsolatorSwitch(uartIsolatorSwitch), uartIsolatorSwitch(uartIsolatorSwitch),
hkReport(this), hkReport(this),
supervisorHandler(supervisorHandler), supervisorHandler(supervisorHandler) {
powerSwitcher(powerSwitcher),
camSwitchId(camSwitchId) {
commandActionHelperQueue = QueueFactory::instance()->createMessageQueue(10); commandActionHelperQueue = QueueFactory::instance()->createMessageQueue(10);
eventQueue = QueueFactory::instance()->createMessageQueue(10); eventQueue = QueueFactory::instance()->createMessageQueue(10);
spParams.maxSize = sizeof(commandBuffer); spParams.maxSize = sizeof(commandBuffer);
@@ -45,7 +38,7 @@ void FreshMpsocHandler::performDeviceOperation(uint8_t opCode) {
if (opCode == OpCode::DEFAULT_OPERATION) { if (opCode == OpCode::DEFAULT_OPERATION) {
performDefaultDeviceOperation(); performDefaultDeviceOperation();
} else if (opCode == OpCode::PARSE_TM and not specialComHelperExecuting) { } else if (opCode == OpCode::PARSE_TM) {
// Just need to call this once, this should take care of processing the whole received // Just need to call this once, this should take care of processing the whole received
// Linux UART RX buffer. // Linux UART RX buffer.
comInterface.readSerialInterface(); comInterface.readSerialInterface();
@@ -84,13 +77,8 @@ void FreshMpsocHandler::performDefaultDeviceOperation() {
} }
} }
// We checked the action queue beforehand, so action commands should always be performed if (mode == MODE_NORMAL and not activeCmdInfo.pending) {
// before normal commands. // TODO: Take care of regular periodic commanding here.
if (mode == MODE_NORMAL and not activeCmdInfo.pending and not specialComHelperExecuting) {
ReturnValue_t result = commandTcGetHkReport();
if (result == returnvalue::OK) {
commandInitHandling(mpsoc::TC_GET_HK_REPORT, MessageQueueIF::NO_QUEUE);
}
} }
if (activeCmdInfo.pending and activeCmdInfo.cmdCountdown.hasTimedOut()) { if (activeCmdInfo.pending and activeCmdInfo.cmdCountdown.hasTimedOut()) {
@@ -165,6 +153,7 @@ ReturnValue_t FreshMpsocHandler::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
specialComHelper.setSequenceCount(&commandSequenceCount);
result = commandActionHelper.initialize(); result = commandActionHelper.initialize();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
@@ -236,11 +225,6 @@ ReturnValue_t FreshMpsocHandler::checkModeCommand(Mode_t mode, Submode_t submode
return HasModesIF::INVALID_SUBMODE; return HasModesIF::INVALID_SUBMODE;
} }
} }
if (submode == mpsoc::Submode::SNAPSHOT and
powerSwitcher.getSwitchState(camSwitchId) != PowerSwitchIF::SWITCH_ON) {
triggerEvent(mpsoc::CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE);
return HasModesIF::TRANS_NOT_ALLOWED;
}
*msToReachTheMode = MPSOC_MODE_CMD_TIMEOUT_MS; *msToReachTheMode = MPSOC_MODE_CMD_TIMEOUT_MS;
return returnvalue::OK; return returnvalue::OK;
} }
@@ -281,11 +265,11 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
return result; return result;
} }
result = specialComHelper.startFlashWrite(flashWritePusCmd.getObcFile(), result = specialComHelper.startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMpsocFile()); flashWritePusCmd.getMPSoCFile());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
commonSpecialComInit(); specialComHelperExecuting = true;
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
case mpsoc::TC_FLASH_READ_FULL_FILE: { case mpsoc::TC_FLASH_READ_FULL_FILE: {
@@ -295,15 +279,12 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
return result; return result;
} }
result = specialComHelper.startFlashRead(flashReadPusCmd.getObcFile(), result = specialComHelper.startFlashRead(flashReadPusCmd.getObcFile(),
flashReadPusCmd.getMpsocFile(), flashReadPusCmd.getMPSoCFile(),
flashReadPusCmd.getReadSize()); flashReadPusCmd.getReadSize());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sif::info << "PLOC MPSoC: Reading " << flashReadPusCmd.getMpsocFile() << " with size " specialComHelperExecuting = true;
<< flashReadPusCmd.getReadSize() << " to " << flashReadPusCmd.getObcFile()
<< std::endl;
commonSpecialComInit();
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
case (mpsoc::OBSW_RESET_SEQ_COUNT_LEGACY): { case (mpsoc::OBSW_RESET_SEQ_COUNT_LEGACY): {
@@ -313,15 +294,12 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
default: default:
break; break;
} }
// For longer commands, do not set these.
// TODO: Do all the stuff the form buildDeviceFromDevice blah did.
executeRegularCmd(actionId, commandedBy, data, size); executeRegularCmd(actionId, commandedBy, data, size);
return returnvalue::OK; return returnvalue::OK;
} }
void FreshMpsocHandler::commonSpecialComInit() {
specialComHelperExecuting = true;
specialComHelper.setCommandSequenceCount(commandSequenceCount.get());
}
/** /**
* @overload * @overload
* @param submode * @param submode
@@ -337,10 +315,6 @@ void FreshMpsocHandler::startTransition(Mode_t newMode, Submode_t submode) {
} else if ((newMode == MODE_ON or newMode == MODE_NORMAL) && } else if ((newMode == MODE_ON or newMode == MODE_NORMAL) &&
((mode == MODE_OFF) or (mode == MODE_UNDEFINED))) { ((mode == MODE_OFF) or (mode == MODE_UNDEFINED))) {
transitionState = TransitionState::TO_ON; transitionState = TransitionState::TO_ON;
} else if (mode == MODE_ON && newMode == MODE_NORMAL) {
hkReport.setReportingEnabled(true);
} else if (mode == MODE_NORMAL && newMode == MODE_ON) {
hkReport.setReportingEnabled(false);
} else if (newMode == MODE_OFF) { } else if (newMode == MODE_OFF) {
transitionState = TransitionState::TO_OFF; transitionState = TransitionState::TO_OFF;
} }
@@ -376,9 +350,7 @@ void FreshMpsocHandler::handleTransitionToOn() {
if (startupState == StartupState::DONE) { if (startupState == StartupState::DONE) {
setMode(targetMode, targetSubmode); setMode(targetMode, targetSubmode);
transitionState = TransitionState::NONE; transitionState = TransitionState::NONE;
if (targetMode == MODE_NORMAL) { hkReport.setReportingEnabled(true);
hkReport.setReportingEnabled(true);
}
powerState = PowerState::IDLE; powerState = PowerState::IDLE;
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
} }
@@ -387,7 +359,7 @@ void FreshMpsocHandler::handleTransitionToOn() {
void FreshMpsocHandler::handleTransitionToOff() { void FreshMpsocHandler::handleTransitionToOff() {
if (handleHwShutdown()) { if (handleHwShutdown()) {
hkReport.setReportingEnabled(false); hkReport.setReportingEnabled(false);
setMode(MODE_OFF, 0); setMode(MODE_OFF);
transitionState = TransitionState::NONE; transitionState = TransitionState::NONE;
activeCmdInfo.reset(); activeCmdInfo.reset();
powerState = PowerState::IDLE; powerState = PowerState::IDLE;
@@ -504,23 +476,6 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
result = commandTcMemRead(commandData, commandDataLen); result = commandTcMemRead(commandData, commandDataLen);
break; break;
} }
case (mpsoc::TC_FLASHFOPEN): {
mpsoc::TcFlashFopen cmd(spParams, commandSequenceCount);
// C string constructor.
std::string filename = std::string(reinterpret_cast<const char*>(commandData));
if (filename.size() > mpsoc::MAX_FILENAME_SIZE) {
return mpsoc::NAME_TOO_LONG;
}
uint8_t mode = commandData[filename.size() + 2];
cmd.setPayload(filename, mode);
result = finishAndSendTc(actionId, cmd);
break;
}
case (mpsoc::TC_FLASHFCLOSE): {
mpsoc::TcFlashFclose cmd(spParams, commandSequenceCount);
result = finishAndSendTc(actionId, cmd);
break;
}
case (mpsoc::TC_FLASHDELETE): { case (mpsoc::TC_FLASHDELETE): {
result = commandTcFlashDelete(commandData, commandDataLen); result = commandTcFlashDelete(commandData, commandDataLen);
break; break;
@@ -563,7 +518,6 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
} }
mpsoc::TcFlashMkfs cmd(spParams, commandSequenceCount, mpsoc::TcFlashMkfs cmd(spParams, commandSequenceCount,
static_cast<mpsoc::FlashId>(commandData[0])); static_cast<mpsoc::FlashId>(commandData[0]));
sif::info << "PLOC MPSoC: Formatting Flash " << (int)commandData[0] << std::endl;
result = finishAndSendTc(actionId, cmd, mpsoc::CMD_TIMEOUT_MKFS); result = finishAndSendTc(actionId, cmd, mpsoc::CMD_TIMEOUT_MKFS);
break; break;
} }
@@ -584,16 +538,9 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
break; break;
} }
case (mpsoc::TC_SIMPLEX_STREAM_FILE): { case (mpsoc::TC_SIMPLEX_STREAM_FILE): {
if (submode != mpsoc::Submode::SNAPSHOT) {
return HasModesIF::INVALID_SUBMODE;
}
result = commandTcSimplexStreamFile(commandData, commandDataLen); result = commandTcSimplexStreamFile(commandData, commandDataLen);
break; break;
} }
case (mpsoc::TC_SPLIT_FILE): {
result = commandTcSplitFile(commandData, commandDataLen);
break;
}
case (mpsoc::TC_DOWNLINK_DATA_MODULATE): { case (mpsoc::TC_DOWNLINK_DATA_MODULATE): {
result = commandTcDownlinkDataModulate(commandData, commandDataLen); result = commandTcDownlinkDataModulate(commandData, commandDataLen);
break; break;
@@ -606,20 +553,16 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
} }
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
commandInitHandling(actionId, commandedBy); activeCmdInfo.start(actionId, commandedBy);
/**
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
*/
comInterface.getComHelper().flushUartRxBuffer();
} }
return result; return result;
} }
void FreshMpsocHandler::commandInitHandling(ActionId_t actionId, MessageQueueId_t commandedBy) {
activeCmdInfo.start(actionId, commandedBy);
/**
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
*/
comInterface.getComHelper().flushUartRxBuffer();
}
ReturnValue_t FreshMpsocHandler::commandTcMemWrite(const uint8_t* commandData, ReturnValue_t FreshMpsocHandler::commandTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@@ -647,7 +590,7 @@ ReturnValue_t FreshMpsocHandler::commandTcMemRead(const uint8_t* commandData,
ReturnValue_t FreshMpsocHandler::commandTcFlashDelete(const uint8_t* commandData, ReturnValue_t FreshMpsocHandler::commandTcFlashDelete(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
if (commandDataLen > mpsoc::FILENAME_FIELD_SIZE) { if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return mpsoc::NAME_TOO_LONG; return mpsoc::NAME_TOO_LONG;
} }
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
@@ -744,15 +687,6 @@ ReturnValue_t FreshMpsocHandler::commandTcCamTakePic(const uint8_t* commandData,
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sif::info << "PLOC MPSoC Take Picture Command" << std::endl;
sif::info << "filename: " << tcCamTakePic.fileName << std::endl;
sif::info << "encoder [Y, Cb, Cr]: [" << (int)tcCamTakePic.encoderSettingY << ", "
<< (int)tcCamTakePic.encoderSettingsCb << ", " << (int)tcCamTakePic.encoderSettingsCr
<< "]" << std::endl;
sif::info << "quantization [Y, Cb, Cr]: [" << tcCamTakePic.quantizationY << ", "
<< tcCamTakePic.quantizationCb << ", " << tcCamTakePic.quantizationCr << "]"
<< std::endl;
sif::info << "bypass compressor: " << (int)tcCamTakePic.bypassCompressor << std::endl;
finishAndSendTc(mpsoc::TC_CAM_TAKE_PIC, tcCamTakePic); finishAndSendTc(mpsoc::TC_CAM_TAKE_PIC, tcCamTakePic);
return returnvalue::OK; return returnvalue::OK;
} }
@@ -768,14 +702,14 @@ ReturnValue_t FreshMpsocHandler::commandTcSimplexStreamFile(const uint8_t* comma
return returnvalue::OK; return returnvalue::OK;
} }
ReturnValue_t FreshMpsocHandler::commandTcSplitFile(const uint8_t* commandData, ReturnValue_t FreshMpsocHandler::commandTcSimplexStoreFile(const uint8_t* commandData,
size_t commandDataLen) { size_t commandDataLen) {
mpsoc::TcSplitFile tcSplitFile(spParams, commandSequenceCount); mpsoc::TcSimplexStoreFile tcSimplexStoreFile(spParams, commandSequenceCount);
ReturnValue_t result = tcSplitFile.setPayload(commandData, commandDataLen); ReturnValue_t result = tcSimplexStoreFile.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
finishAndSendTc(mpsoc::TC_SPLIT_FILE, tcSplitFile); finishAndSendTc(mpsoc::TC_SIMPLEX_STORE_FILE, tcSimplexStoreFile);
return returnvalue::OK; return returnvalue::OK;
} }
@@ -809,18 +743,18 @@ ReturnValue_t FreshMpsocHandler::commandTcModeSnapshot() {
ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc::TcBase& tcBase, ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc::TcBase& tcBase,
uint32_t cmdCountdownMs) { uint32_t cmdCountdownMs) {
// Emit warning but still send command.
if (specialComHelperExecuting) {
sif::warning << "PLOC MPSoC: Sending command even though special COM helper is executing"
<< std::endl;
}
ReturnValue_t result = tcBase.finishPacket(); ReturnValue_t result = tcBase.finishPacket();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
// TODO: We should find a way so this works with the old implementation.
commandSequenceCount++; commandSequenceCount++;
mpsoc::printTxPacket(tcBase); if (MPSOC_TX_WIRETAPPING) {
sif::debug << "SEND MPSOC packet. APID 0x" << std::hex << std::setw(3) << tcBase.getApid()
<< " Size " << std::dec << tcBase.getFullPacketLen() << " SSC "
<< tcBase.getSeqCount() << std::endl;
}
activeCmdInfo.cmdCountdown.setTimeout(cmdCountdownMs); activeCmdInfo.cmdCountdown.setTimeout(cmdCountdownMs);
activeCmdInfo.cmdCountdown.resetTimer(); activeCmdInfo.cmdCountdown.resetTimer();
activeCmdInfo.pending = true; activeCmdInfo.pending = true;
@@ -830,10 +764,11 @@ ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc:
} }
void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) { void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
// TODO: Shouldn't we check for specific events?
object_id_t objectId = eventMessage->getReporter(); object_id_t objectId = eventMessage->getReporter();
switch (objectId) { switch (objectId) {
case objects::PLOC_MPSOC_HELPER: { case objects::PLOC_MPSOC_HANDLER: {
commonSpecialComStop(); specialComHelperExecuting = false;
break; break;
} }
default: default:
@@ -841,10 +776,6 @@ void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
break; break;
} }
} }
void FreshMpsocHandler::commonSpecialComStop() {
specialComHelperExecuting = false;
commandSequenceCount.set(specialComHelper.getCommandSequenceCount());
}
void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) { void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
if (transitionState == TransitionState::SUBMODE) { if (transitionState == TransitionState::SUBMODE) {
@@ -865,11 +796,17 @@ void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
ReturnValue_t FreshMpsocHandler::handleDeviceReply() { ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
const auto& replyReader = comInterface.getSpReader(); // SpacePacketReader spacePacket;
// spacePacket.setReadOnlyData(start, remainingSize);
auto& replyReader = comInterface.getSpReader();
if (replyReader.isNull()) { if (replyReader.isNull()) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
mpsoc::printRxPacket(replyReader); if (MPSOC_RX_WIRETAPPING) {
sif::debug << "RECV MPSOC packet. APID 0x" << std::hex << std::setw(3) << replyReader.getApid()
<< std::dec << " Size " << replyReader.getFullPacketLen() << " SSC "
<< replyReader.getSequenceCount() << std::endl;
}
uint16_t apid = replyReader.getApid(); uint16_t apid = replyReader.getApid();
switch (apid) { switch (apid) {
@@ -916,14 +853,15 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
default: { default: {
sif::debug << "FreshMpsocHandler:: Reply has invalid APID 0x" << std::hex << std::setfill('0') sif::debug << "FreshMpsocHandler:: Reply has invalid APID 0x" << std::hex << std::setfill('0')
<< std::setw(2) << apid << std::dec << std::endl; << std::setw(2) << apid << std::dec << std::endl;
//*foundLen = remainingSize;
return mpsoc::INVALID_APID; return mpsoc::INVALID_APID;
} }
} }
// TODO: We should implement some way so this can also be used with the former implementation.
uint16_t sequenceCount = replyReader.getSequenceCount(); uint16_t sequenceCount = replyReader.getSequenceCount();
if (sequenceCount != lastReplySequenceCount + 1) { if (sequenceCount != lastReplySequenceCount + 1) {
// We could trigger event for possible missing reply packet to inform operator, but I don't // TODO: Trigger event for possible missing reply packet to inform operator.
// think this is properly implemented and used on the MPSoC side anymore.
} }
lastReplySequenceCount = sequenceCount; lastReplySequenceCount = sequenceCount;
@@ -978,6 +916,7 @@ ReturnValue_t FreshMpsocHandler::handleAckReport() {
switch (replyReader.getApid()) { switch (replyReader.getApid()) {
case mpsoc::apid::ACK_FAILURE: { case mpsoc::apid::ACK_FAILURE: {
// DeviceCommandId_t commandId = getPendingCommand();
uint16_t status = mpsoc::getStatusFromRawData(replyReader.getFullData()); uint16_t status = mpsoc::getStatusFromRawData(replyReader.getFullData());
sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl; sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(mpsoc::ACK_FAILURE, activeCmdInfo.pendingCmd, status); triggerEvent(mpsoc::ACK_FAILURE, activeCmdInfo.pendingCmd, status);
@@ -1261,9 +1200,7 @@ bool FreshMpsocHandler::handleHwShutdown() {
supvTransitionCd.resetTimer(); supvTransitionCd.resetTimer();
powerState = PowerState::PENDING_SHUTDOWN; powerState = PowerState::PENDING_SHUTDOWN;
} else { } else {
if ((this->mode != MODE_OFF) and (this->mode != MODE_UNDEFINED)) { triggerEvent(mpsoc::SUPV_NOT_ON, 0);
triggerEvent(mpsoc::SUPV_NOT_ON, 0);
}
powerState = PowerState::DONE; powerState = PowerState::DONE;
} }
} }

View File

@@ -1,4 +1,3 @@
#include "fsfw/action/ActionMessage.h"
#include "fsfw/action/CommandsActionsIF.h" #include "fsfw/action/CommandsActionsIF.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/devicehandlers/FreshDeviceHandlerBase.h" #include "fsfw/devicehandlers/FreshDeviceHandlerBase.h"
@@ -6,14 +5,15 @@
#include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/modes/ModeMessage.h" #include "fsfw/modes/ModeMessage.h"
#include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/power/PowerSwitchIF.h"
#include "fsfw/power/definitions.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw_hal/linux/gpio/Gpio.h" #include "fsfw_hal/linux/gpio/Gpio.h"
#include "linux/payload/MpsocCommunication.h" #include "linux/payload/MpsocCommunication.h"
#include "linux/payload/PlocMpsocSpecialComHelper.h" #include "linux/payload/PlocMpsocSpecialComHelper.h"
#include "linux/payload/plocMpsocHelpers.h" #include "linux/payload/plocMpsocHelpers.h"
static constexpr bool MPSOC_TX_WIRETAPPING = true;
static constexpr bool MPSOC_RX_WIRETAPPING = true;
class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsIF { class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsIF {
public: public:
enum OpCode { DEFAULT_OPERATION = 0, PARSE_TM = 1 }; enum OpCode { DEFAULT_OPERATION = 0, PARSE_TM = 1 };
@@ -21,8 +21,7 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface, FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface,
PlocMpsocSpecialComHelper& specialComHelper, Gpio uartIsolatorSwitch, PlocMpsocSpecialComHelper& specialComHelper, Gpio uartIsolatorSwitch,
object_id_t supervisorHandler, PowerSwitchIF& powerSwitcher, object_id_t supervisorHandler);
power::Switch_t camSwitchId);
/** /**
* Periodic helper executed function, implemented by child class. * Periodic helper executed function, implemented by child class.
@@ -132,8 +131,6 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
TmMemReadReport tmMemReadReport; TmMemReadReport tmMemReadReport;
uint32_t lastReplySequenceCount = 0; uint32_t lastReplySequenceCount = 0;
uint8_t skipSupvCommandingToOn = false; uint8_t skipSupvCommandingToOn = false;
PowerSwitchIF& powerSwitcher;
power::Switch_t camSwitchId;
// HK manager abstract functions. // HK manager abstract functions.
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
@@ -187,7 +184,7 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
ReturnValue_t commandTcModeIdle(); ReturnValue_t commandTcModeIdle();
ReturnValue_t commandTcCamTakePic(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t commandTcCamTakePic(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t commandTcSimplexStreamFile(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t commandTcSimplexStreamFile(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t commandTcSplitFile(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t commandTcSimplexStoreFile(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t commandTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t commandTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t commandTcModeSnapshot(); ReturnValue_t commandTcModeSnapshot();
@@ -206,7 +203,4 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
void stopSpecialComHelper(); void stopSpecialComHelper();
void commandSubmodeTransition(); void commandSubmodeTransition();
void commonSpecialComInit();
void commonSpecialComStop();
void commandInitHandling(ActionId_t actionId, MessageQueueId_t commandedBy);
}; };

View File

@@ -13,9 +13,6 @@ MpsocCommunication::MpsocCommunication(object_id_t objectId, SerialConfig cfg)
ReturnValue_t MpsocCommunication::initialize() { return helper.initialize(); } ReturnValue_t MpsocCommunication::initialize() { return helper.initialize(); }
ReturnValue_t MpsocCommunication::send(const uint8_t* data, size_t dataLen) { ReturnValue_t MpsocCommunication::send(const uint8_t* data, size_t dataLen) {
if (MPSOC_LOW_LEVEL_TX_WIRETAPPING) {
sif::debug << "SEND MPSOC packet with size " << dataLen << std::endl;
}
return helper.send(data, dataLen); return helper.send(data, dataLen);
} }
@@ -30,7 +27,7 @@ ReturnValue_t MpsocCommunication::parseAndRetrieveNextPacket() {
return returnvalue::OK; return returnvalue::OK;
} }
readRingBuf.readData(readBuf, availableReadData); readRingBuf.readData(readBuf, availableReadData);
spReader.setReadOnlyData(readBuf, sizeof(readBuf)); spReader.setReadOnlyData(readBuf, availableReadData);
auto res = spReader.checkSize(); auto res = spReader.checkSize();
if (res != returnvalue::OK) { if (res != returnvalue::OK) {
return res; return res;

View File

@@ -9,8 +9,7 @@
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h" #include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "linux/payload/SerialCommunicationHelper.h" #include "linux/payload/SerialCommunicationHelper.h"
static constexpr bool MPSOC_LOW_LEVEL_TX_WIRETAPPING = false; static constexpr bool MPSOC_LOW_LEVEL_RX_WIRETAPPING = true;
static constexpr bool MPSOC_LOW_LEVEL_RX_WIRETAPPING = false;
class MpsocCommunication : public SystemObject { class MpsocCommunication : public SystemObject {
public: public:

View File

@@ -6,16 +6,14 @@
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include "fsfw/serviceinterface/ServiceInterfacePrinter.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "linux/payload/MpsocCommunication.h" #include "linux/payload/MpsocCommunication.h"
#include "linux/payload/plocMpsocHelpers.h"
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
#include "bsp_q7s/fs/FilesystemHelper.h" #include "bsp_q7s/fs/FilesystemHelper.h"
#endif #endif
#include "mission/utility/Timestamp.h"
using namespace ploc; using namespace ploc;
PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId, PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId,
@@ -53,9 +51,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
case InternalState::FLASH_WRITE: { case InternalState::FLASH_WRITE: {
result = performFlashWrite(); result = performFlashWrite();
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, txSequenceCount.get()); triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, sequenceCount->get());
} else { } else {
triggerEvent(MPSOC_FLASH_WRITE_FAILED, txSequenceCount.get()); triggerEvent(MPSOC_FLASH_WRITE_FAILED, sequenceCount->get());
} }
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
break; break;
@@ -63,10 +61,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
case InternalState::FLASH_READ: { case InternalState::FLASH_READ: {
result = performFlashRead(); result = performFlashRead();
if (result == returnvalue::OK) { if (result == returnvalue::OK) {
triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, txSequenceCount.get()); triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, sequenceCount->get());
} else { } else {
sif::printWarning("PLOC MPSoC Helper: Flash read failed with code %04x\n", result); triggerEvent(MPSOC_FLASH_READ_FAILED, sequenceCount->get());
triggerEvent(MPSOC_FLASH_READ_FAILED, txSequenceCount.get(), result);
} }
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
break; break;
@@ -78,12 +75,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode)
} }
} }
void PlocMpsocSpecialComHelper::setCommandSequenceCount(uint16_t sequenceCount_) { void PlocMpsocSpecialComHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
txSequenceCount.set(sequenceCount_); sequenceCount = sequenceCount_;
}
uint16_t PlocMpsocSpecialComHelper::getCommandSequenceCount() const {
return txSequenceCount.get();
} }
ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile, ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile,
@@ -155,7 +148,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength); file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength);
bytesRead += dataLength; bytesRead += dataLength;
remainingSize -= dataLength; remainingSize -= dataLength;
mpsoc::TcFlashWrite tc(spParams, txSequenceCount); mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
result = tc.setPayload(fileBuf.data(), dataLength); result = tc.setPayload(fileBuf.data(), dataLength);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@@ -164,7 +157,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
txSequenceCount.increment(); (*sequenceCount)++;
result = handlePacketTransmissionNoReply(tc); result = handlePacketTransmissionNoReply(tc);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@@ -179,12 +172,8 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
std::error_code e; std::error_code e;
if (std::filesystem::exists(flashReadAndWrite.obcFile)) { std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary);
// Truncate the file first. if (ofile.bad()) {
std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::binary | std::ios::trunc);
}
std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::binary | std::ios::app);
if (ofile.bad() or not ofile.is_open()) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
ReturnValue_t result = flashfopen(mpsoc::FileAccessModes::READ); ReturnValue_t result = flashfopen(mpsoc::FileAccessModes::READ);
@@ -207,7 +196,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
std::filesystem::remove(flashReadAndWrite.obcFile, e); std::filesystem::remove(flashReadAndWrite.obcFile, e);
return FILE_READ_ERROR; return FILE_READ_ERROR;
} }
mpsoc::TcFlashRead flashReadRequest(spParams, txSequenceCount); mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
result = flashReadRequest.setPayload(nextReadSize); result = flashReadRequest.setPayload(nextReadSize);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
std::filesystem::remove(flashReadAndWrite.obcFile, e); std::filesystem::remove(flashReadAndWrite.obcFile, e);
@@ -218,7 +207,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
std::filesystem::remove(flashReadAndWrite.obcFile, e); std::filesystem::remove(flashReadAndWrite.obcFile, e);
return result; return result;
} }
txSequenceCount.increment(); (*sequenceCount)++;
result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize); result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
std::filesystem::remove(flashReadAndWrite.obcFile, e); std::filesystem::remove(flashReadAndWrite.obcFile, e);
@@ -235,7 +224,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) { ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
mpsoc::TcFlashFopen flashFopen(spParams, txSequenceCount); mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode); ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@@ -244,7 +233,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
txSequenceCount.increment(); (*sequenceCount)++;
result = handlePacketTransmissionNoReply(flashFopen); result = handlePacketTransmissionNoReply(flashFopen);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@@ -254,12 +243,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() { ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() {
spParams.buf = commandBuffer; spParams.buf = commandBuffer;
mpsoc::TcFlashFclose flashFclose(spParams, txSequenceCount); mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
ReturnValue_t result = flashFclose.finishPacket(); ReturnValue_t result = flashFclose.finishPacket();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
txSequenceCount.increment(); (*sequenceCount)++;
result = handlePacketTransmissionNoReply(flashFclose); result = handlePacketTransmissionNoReply(flashFclose);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
@@ -282,7 +271,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
auto& spReader = comInterface.getSpReader();
// We have the nominal case where the flash read report appears first, or the case where we // We have the nominal case where the flash read report appears first, or the case where we
// get an EXE failure immediately. // get an EXE failure immediately.
@@ -293,7 +281,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc
} }
return handleExe(); return handleExe();
} else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) { } else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) {
handleExeFailure(spReader); handleExeFailure();
} else { } else {
triggerEvent(MPSOC_EXE_INVALID_APID, spReader.getApid(), static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_EXE_INVALID_APID, spReader.getApid(), static_cast<uint32_t>(internalState));
sif::warning << "PLOC MPSoC: Expected execution report " sif::warning << "PLOC MPSoC: Expected execution report "
@@ -317,7 +305,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::S
ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) { ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) {
ReturnValue_t result = comInterface.send(tc.getFullPacket(), tc.getFullPacketLen()); ReturnValue_t result = comInterface.send(tc.getFullPacket(), tc.getFullPacketLen());
mpsoc::printTxPacket(tc);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
triggerEvent(MPSOC_SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState));
@@ -336,8 +323,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
const auto& spReader = comInterface.getSpReader();
uint16_t apid = spReader.getApid(); uint16_t apid = spReader.getApid();
if (apid != mpsoc::apid::ACK_SUCCESS) { if (apid != mpsoc::apid::ACK_SUCCESS) {
handleAckApidFailure(spReader); handleAckApidFailure(spReader);
@@ -346,7 +331,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMpsocSpecialComHelper::handleAckApidFailure(const SpacePacketReader& reader) { void PlocMpsocSpecialComHelper::handleAckApidFailure(const ploc::SpTmReader& reader) {
uint16_t apid = reader.getApid(); uint16_t apid = reader.getApid();
if (apid == mpsoc::apid::ACK_FAILURE) { if (apid == mpsoc::apid::ACK_FAILURE) {
uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData()); uint16_t status = mpsoc::getStatusFromRawData(reader.getFullData());
@@ -370,10 +355,9 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
const auto& spReader = comInterface.getSpReader();
uint16_t apid = spReader.getApid(); uint16_t apid = spReader.getApid();
if (apid == mpsoc::apid::EXE_FAILURE) { if (apid == mpsoc::apid::EXE_FAILURE) {
handleExeFailure(spReader); handleExeFailure();
return returnvalue::FAILED; return returnvalue::FAILED;
} else if (apid != mpsoc::apid::EXE_SUCCESS) { } else if (apid != mpsoc::apid::EXE_SUCCESS) {
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
@@ -383,7 +367,7 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
return returnvalue::OK; return returnvalue::OK;
} }
void PlocMpsocSpecialComHelper::handleExeFailure(const SpacePacketReader& spReader) { void PlocMpsocSpecialComHelper::handleExeFailure() {
uint16_t status = mpsoc::getStatusFromRawData(spReader.getFullData()); uint16_t status = mpsoc::getStatusFromRawData(spReader.getFullData());
sif::warning << "PLOC MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl; sif::warning << "PLOC MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
@@ -392,32 +376,46 @@ void PlocMpsocSpecialComHelper::handleExeFailure(const SpacePacketReader& spRead
ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() { ReturnValue_t PlocMpsocSpecialComHelper::handleTmReception() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
tmCountdown.resetTimer(); tmCountdown.resetTimer();
size_t readBytes = 0;
size_t currentBytes = 0;
uint32_t usleepDelay = 5; uint32_t usleepDelay = 5;
size_t fullPacketLen = 0;
while (true) { while (true) {
if (tmCountdown.hasTimedOut()) { if (tmCountdown.hasTimedOut()) {
triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs()); triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs());
return returnvalue::FAILED; return returnvalue::FAILED;
} }
result = tryReceiveNextReply(); result = receive(tmBuf.data() + readBytes, 6, &currentBytes);
if (result == MpsocCommunication::PACKET_RECEIVED) {
// Need to convert this, we are faking a synchronous API here.
result = returnvalue::OK;
break;
}
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
if (result == MpsocCommunication::FAULTY_PACKET_SIZE) {
sif::printWarning("PLOC MPSoC Helper: retrieving next reply failed: faulty packet size\n");
} else if (result == MpsocCommunication::CRC_CHECK_FAILED) {
sif::printWarning("PLOC MPSoC Helper: retrieving next reply failed: CRC check failed\n");
}
sif::printWarning("PLOC MPSoC Helper: retrieving next reply failed with code %d\n", result);
return result; return result;
} }
spReader.setReadOnlyData(tmBuf.data(), tmBuf.size());
fullPacketLen = spReader.getFullPacketLen();
readBytes += currentBytes;
if (readBytes == 6) {
break;
}
usleep(usleepDelay); usleep(usleepDelay);
if (usleepDelay < 200000) { if (usleepDelay < 200000) {
usleepDelay *= 4; usleepDelay *= 4;
} }
} }
while (true) {
if (tmCountdown.hasTimedOut()) {
triggerEvent(MPSOC_READ_TIMEOUT, tmCountdown.getTimeoutMs());
return returnvalue::FAILED;
}
result = receive(tmBuf.data() + readBytes, fullPacketLen - readBytes, &currentBytes);
readBytes += currentBytes;
if (fullPacketLen == readBytes) {
break;
}
usleep(usleepDelay);
if (usleepDelay < 200000) {
usleepDelay *= 4;
}
}
// arrayprinter::print(tmBuf.data(), readBytes);
return result; return result;
} }
@@ -427,7 +425,6 @@ ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofi
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
auto& spReader = comInterface.getSpReader();
uint16_t apid = spReader.getApid(); uint16_t apid = spReader.getApid();
if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) { if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) {
triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR); triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR);
@@ -493,19 +490,25 @@ ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string o
} }
ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() { ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() {
const auto& spReader = comInterface.getSpReader();
ReturnValue_t result = spReader.checkSize(); ReturnValue_t result = spReader.checkSize();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::error << "PLOC MPSoC: 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); triggerEvent(MPSOC_TM_SIZE_ERROR);
return result; return result;
} }
rxSequenceCount = spReader.getSequenceCount(); // No CRC check, this is already done by the communication interface..
mpsoc::printRxPacket(spReader); uint16_t recvSeqCnt = spReader.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; return returnvalue::OK;
} }
ReturnValue_t PlocMpsocSpecialComHelper::tryReceiveNextReply() { ReturnValue_t PlocMpsocSpecialComHelper::receive(uint8_t* data, size_t requestBytes,
size_t* readBytes) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
result = comInterface.readSerialInterface(); result = comInterface.readSerialInterface();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@@ -513,5 +516,11 @@ ReturnValue_t PlocMpsocSpecialComHelper::tryReceiveNextReply() {
static_cast<uint32_t>(static_cast<uint32_t>(internalState))); static_cast<uint32_t>(static_cast<uint32_t>(internalState)));
return returnvalue::FAILED; return returnvalue::FAILED;
} }
return comInterface.parseAndRetrieveNextPacket(); result = comInterface.parseAndRetrieveNextPacket();
if (result == MpsocCommunication::PACKET_RECEIVED) {
auto& spReader = comInterface.getSpReader();
// Maybe unnecessary copy, but the easiest way to get this done for now..
std::memcpy(data, spReader.getFullData(), spReader.getFullPacketLen());
}
return result;
} }

View File

@@ -10,7 +10,6 @@
#include "fsfw/osal/linux/BinarySemaphore.h" #include "fsfw/osal/linux/BinarySemaphore.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "linux/payload/MpsocCommunication.h" #include "linux/payload/MpsocCommunication.h"
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
@@ -114,8 +113,7 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
/** /**
* @brief Sets the sequence count object responsible for the sequence count handling * @brief Sets the sequence count object responsible for the sequence count handling
*/ */
void setCommandSequenceCount(uint16_t sequenceCount_); void setSequenceCount(SourceSequenceCounter* sequenceCount_);
uint16_t getCommandSequenceCount() const;
private: private:
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER; static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER;
@@ -171,9 +169,8 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
// CookieIF* comCookie = nullptr; // CookieIF* comCookie = nullptr;
MpsocCommunication& comInterface; MpsocCommunication& comInterface;
// Sequence count, must be set by Ploc MPSoC Handler // Sequence count, must be set by Ploc MPSoC Handler
// ploc::SpTmReader spReader; SourceSequenceCounter* sequenceCount = nullptr;
uint16_t rxSequenceCount = 0; ploc::SpTmReader spReader;
SourceSequenceCounter txSequenceCount = 0;
void resetHelper(); void resetHelper();
ReturnValue_t performFlashWrite(); ReturnValue_t performFlashWrite();
@@ -185,13 +182,13 @@ class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF
size_t expectedReadLen); size_t expectedReadLen);
ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen); ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen);
ReturnValue_t sendCommand(ploc::SpTcBase& tc); ReturnValue_t sendCommand(ploc::SpTcBase& tc);
ReturnValue_t tryReceiveNextReply(); ReturnValue_t receive(uint8_t* data, size_t requestBytes, size_t* readBytes);
ReturnValue_t handleAck(); ReturnValue_t handleAck();
ReturnValue_t handleExe(); ReturnValue_t handleExe();
ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile);
ReturnValue_t fileCheck(std::string obcFile); ReturnValue_t fileCheck(std::string obcFile);
void handleAckApidFailure(const SpacePacketReader& reader); void handleAckApidFailure(const ploc::SpTmReader& reader);
void handleExeFailure(const SpacePacketReader& reader); void handleExeFailure();
ReturnValue_t handleTmReception(); ReturnValue_t handleTmReception();
ReturnValue_t checkReceivedTm(); ReturnValue_t checkReceivedTm();
}; };

View File

@@ -437,8 +437,6 @@ ReturnValue_t PlocSupvUartManager::writeUpdatePackets() {
// Useful to allow restarting the update // Useful to allow restarting the update
triggerEvent(SUPV_UPDATE_PROGRESS, buildProgParams1(progPercent, update.sequenceCount), triggerEvent(SUPV_UPDATE_PROGRESS, buildProgParams1(progPercent, update.sequenceCount),
update.bytesWritten); update.bytesWritten);
sif::info << "PLOC SUPV update progress " << (int)progPercent << " % at "
<< update.bytesWritten << " bytes" << std::endl;
} }
} }
supv::WriteMemory packet(spParams); supv::WriteMemory packet(spParams);

View File

@@ -1,8 +1,5 @@
#include "plocMpsocHelpers.h" #include "plocMpsocHelpers.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "mission/payload/plocSpBase.h"
uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) { uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) {
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
} }
@@ -16,10 +13,6 @@ std::string mpsoc::getStatusString(uint16_t status) {
return "Incorrect length"; return "Incorrect length";
break; break;
} }
case (mpsoc::statusCode::FLASH_DRIVE_ERROR): {
return "flash drive error";
break;
}
case (mpsoc::statusCode::INCORRECT_CRC): { case (mpsoc::statusCode::INCORRECT_CRC): {
return "Incorrect crc"; return "Incorrect crc";
break; break;
@@ -100,19 +93,3 @@ std::string mpsoc::getStatusString(uint16_t status) {
} }
return ""; return "";
} }
void mpsoc::printRxPacket(const SpacePacketReader& spReader) {
if (mpsoc::MPSOC_RX_WIRETAPPING) {
sif::debug << "RECV MPSOC packet. APID 0x" << std::hex << std::setw(3) << spReader.getApid()
<< std::dec << " Size " << spReader.getFullPacketLen() << " SSC "
<< spReader.getSequenceCount() << std::endl;
}
}
void mpsoc::printTxPacket(const ploc::SpTcBase& tcBase) {
if (mpsoc::MPSOC_TX_WIRETAPPING) {
sif::debug << "SEND MPSOC packet. APID 0x" << std::hex << std::setw(3) << tcBase.getApid()
<< " Size " << std::dec << tcBase.getFullPacketLen() << " SSC "
<< tcBase.getSeqCount() << std::endl;
}
}

View File

@@ -5,65 +5,20 @@
#include <fsfw/devicehandlers/DeviceHandlerIF.h> #include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <mission/payload/plocSpBase.h> #include <mission/payload/plocSpBase.h>
#include "eive/definitions.h"
#include "eive/eventSubsystemIds.h" #include "eive/eventSubsystemIds.h"
#include "eive/resultClassIds.h" #include "eive/resultClassIds.h"
#include "fsfw/action/HasActionsIF.h" #include "fsfw/action/HasActionsIF.h"
#include "fsfw/events/Event.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serialize/SerializeIF.h" #include "fsfw/serialize/SerializeIF.h"
namespace mpsoc { namespace mpsoc {
static constexpr bool MPSOC_TX_WIRETAPPING = false;
static constexpr bool MPSOC_RX_WIRETAPPING = false;
static constexpr size_t CRC_SIZE = 2;
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public ploc::SpTcBase {
public:
virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = CRC_SIZE;
/**
* @brief Constructor
*
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
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);
}
/**
* @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 finishPacket() {
updateSpFields();
ReturnValue_t res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
return calcAndSetCrc();
}
};
void printRxPacket(const SpacePacketReader& spReader);
void printTxPacket(const ploc::SpTcBase& tcBase);
static constexpr uint32_t DEFAULT_CMD_TIMEOUT_MS = 5000; static constexpr uint32_t DEFAULT_CMD_TIMEOUT_MS = 5000;
static constexpr uint32_t CMD_TIMEOUT_MKFS = 15000; static constexpr uint32_t CMD_TIMEOUT_MKFS = 15000;
enum FlashId : uint8_t { FLASH_0 = 0, FLASH_1 = 1 }; enum FlashId : uint8_t { FLASH_0 = 0, FLASH_1 = 0 };
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF; static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF;
@@ -113,11 +68,7 @@ static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH);
//! [EXPORT] : [COMMENT] SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for //! [EXPORT] : [COMMENT] SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for
//! ON transition. //! ON transition.
static constexpr Event SUPV_NOT_ON = event::makeEvent(SUBSYSTEM_ID, 7, severity::LOW); static constexpr Event SUPV_NOT_ON = event::makeEvent(SUBSYSTEM_ID, 7, severity::LOW);
//! [EXPORT] : [COMMENT] SUPV reply timeout.
static constexpr Event SUPV_REPLY_TIMEOUT = event::makeEvent(SUBSYSTEM_ID, 8, severity::LOW); static constexpr Event SUPV_REPLY_TIMEOUT = event::makeEvent(SUBSYSTEM_ID, 8, severity::LOW);
//! [EXPORT] : [COMMENT] Camera must be commanded on first.
static constexpr Event CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE =
event::makeEvent(SUBSYSTEM_ID, 9, severity::LOW);
enum ParamId : uint8_t { SKIP_SUPV_ON_COMMANDING = 0x01 }; enum ParamId : uint8_t { SKIP_SUPV_ON_COMMANDING = 0x01 };
@@ -210,7 +161,7 @@ static const DeviceCommandId_t TC_FLASH_GET_DIRECTORY_CONTENT = 28;
static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29; static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29;
static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30; static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30;
// Store file on MPSoC. // Store file on MPSoC.
static const DeviceCommandId_t TC_SPLIT_FILE = 31; static const DeviceCommandId_t TC_SIMPLEX_STORE_FILE = 31;
static const DeviceCommandId_t TC_VERIFY_BOOT = 32; static const DeviceCommandId_t TC_VERIFY_BOOT = 32;
static const DeviceCommandId_t TC_ENABLE_TC_EXECTION = 33; static const DeviceCommandId_t TC_ENABLE_TC_EXECTION = 33;
static const DeviceCommandId_t TC_FLASH_MKFS = 34; static const DeviceCommandId_t TC_FLASH_MKFS = 34;
@@ -220,6 +171,8 @@ static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT_LEGACY = 50;
static const uint16_t SIZE_ACK_REPORT = 14; static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14;
// static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
// static const uint16_t SIZE_TM_CAM_CMD_RPT = 18;
static constexpr size_t SIZE_TM_HK_REPORT = 369; static constexpr size_t SIZE_TM_HK_REPORT = 369;
enum Submode : uint8_t { IDLE_OR_NONE = 0, REPLAY = 1, SNAPSHOT = 2 }; enum Submode : uint8_t { IDLE_OR_NONE = 0, REPLAY = 1, SNAPSHOT = 2 };
@@ -284,15 +237,15 @@ static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
static const uint8_t STATUS_OFFSET = 10; static const uint8_t STATUS_OFFSET = 10;
static constexpr size_t CRC_SIZE = 2;
/** /**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service * The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8. * 8.
*/ */
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6; static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
static const size_t FILENAME_FIELD_SIZE = 256; static const size_t MAX_FILENAME_SIZE = 256;
// Subtract size of NULL terminator.
static const size_t MAX_FILENAME_SIZE = FILENAME_FIELD_SIZE - 1;
/** /**
* PLOC space packet length for fixed size packets. This is the size of the whole packet data * PLOC space packet length for fixed size packets. This is the size of the whole packet data
@@ -329,7 +282,6 @@ static const uint16_t TC_SIMPLEX_SEND_FILE_DELAY = 80;
namespace statusCode { namespace statusCode {
static const uint16_t DEFAULT_ERROR_CODE = 0x1; static const uint16_t DEFAULT_ERROR_CODE = 0x1;
static constexpr uint16_t FLASH_DRIVE_ERROR = 0xb;
static const uint16_t UNKNOWN_APID = 0x5DD; static const uint16_t UNKNOWN_APID = 0x5DD;
static const uint16_t INCORRECT_LENGTH = 0x5DE; static const uint16_t INCORRECT_LENGTH = 0x5DE;
static const uint16_t INCORRECT_CRC = 0x5DF; static const uint16_t INCORRECT_CRC = 0x5DF;
@@ -356,10 +308,47 @@ static const uint16_t RESERVED_3 = 0x5F3;
static const uint16_t RESERVED_4 = 0x5F4; static const uint16_t RESERVED_4 = 0x5F4;
} // namespace statusCode } // namespace statusCode
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public ploc::SpTcBase {
public:
virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = CRC_SIZE;
/**
* @brief Constructor
*
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
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);
}
/**
* @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 finishPacket() {
updateSpFields();
ReturnValue_t res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
return calcAndSetCrc();
}
};
/** /**
* @brief This class helps to build the memory read command for the PLOC. * @brief This class helps to build the memory read command for the PLOC.
*/ */
class TcMemRead : public mpsoc::TcBase { class TcMemRead : public TcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@@ -409,7 +398,7 @@ class TcMemRead : public mpsoc::TcBase {
* @brief This class helps to generate the space packet to write data to a memory address within * @brief This class helps to generate the space packet to write data to a memory address within
* the PLOC. * the PLOC.
*/ */
class TcMemWrite : public mpsoc::TcBase { class TcMemWrite : public TcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@@ -459,21 +448,24 @@ class TcMemWrite : public mpsoc::TcBase {
/** /**
* @brief Class to help creation of flash fopen command. * @brief Class to help creation of flash fopen command.
*/ */
class TcFlashFopen : public mpsoc::TcBase { class FlashFopen : public TcBase {
public: public:
TcFlashFopen(ploc::SpTcParams params, uint16_t sequenceCount) FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} : TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
ReturnValue_t setPayload(std::string filename, uint8_t mode) { ReturnValue_t setPayload(std::string filename, uint8_t mode) {
accessMode = mode; accessMode = mode;
size_t nameSize = filename.size();
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
ReturnValue_t result = checkPayloadLen(); ReturnValue_t result = checkPayloadLen();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
std::memset(payloadStart, 0, FILENAME_FIELD_SIZE); std::memcpy(payloadStart, filename.c_str(), nameSize);
std::memcpy(payloadStart, filename.c_str(), filename.size()); // payloadStart[nameSize] = NULL_TERMINATOR;
payloadStart[FILENAME_FIELD_SIZE] = accessMode; std::memset(payloadStart + nameSize, 0, 256 - nameSize);
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + 1 + CRC_SIZE); // payloadStart[255] = NULL_TERMINATOR;
payloadStart[256] = accessMode;
return returnvalue::OK; return returnvalue::OK;
} }
@@ -484,9 +476,9 @@ class TcFlashFopen : public mpsoc::TcBase {
/** /**
* @brief Class to help creation of flash fclose command. * @brief Class to help creation of flash fclose command.
*/ */
class TcFlashFclose : public TcBase { class FlashFclose : public TcBase {
public: public:
TcFlashFclose(ploc::SpTcParams params, uint16_t sequenceCount) FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) { : TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {
spParams.setFullPayloadLen(CRC_SIZE); spParams.setFullPayloadLen(CRC_SIZE);
} }
@@ -513,14 +505,8 @@ class TcFlashMkfs : public TcBase {
public: public:
TcFlashMkfs(ploc::SpTcParams params, uint16_t sequenceCount, FlashId flashId) TcFlashMkfs(ploc::SpTcParams params, uint16_t sequenceCount, FlashId flashId)
: TcBase(params, apid::TC_FLASH_MKFS, sequenceCount) { : TcBase(params, apid::TC_FLASH_MKFS, sequenceCount) {
const char* flashIdStr = "0:\\"; spParams.setFullPayloadLen(1 + CRC_SIZE);
if (flashId == FlashId::FLASH_1) { payloadStart[0] = flashId;
flashIdStr = "1:\\";
}
std::memcpy(payloadStart, flashIdStr, 3);
// Null terminator
payloadStart[3] = 0;
spParams.setFullPayloadLen(4 + CRC_SIZE);
} }
}; };
@@ -583,6 +569,15 @@ class TcFlashRead : public TcBase {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
updateSpFields();
result = checkSizeAndSerializeHeader();
if (result != returnvalue::OK) {
return result;
}
result = calcAndSetCrc();
if (result != returnvalue::OK) {
return result;
}
readSize = readLen; readSize = readLen;
return result; return result;
} }
@@ -600,14 +595,20 @@ class TcFlashDelete : public TcBase {
ReturnValue_t setPayload(std::string filename) { ReturnValue_t setPayload(std::string filename) {
size_t nameSize = filename.size(); size_t nameSize = filename.size();
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE); spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
auto res = checkPayloadLen(); auto res = checkPayloadLen();
if (res != returnvalue::OK) { if (res != returnvalue::OK) {
return res; return res;
} }
std::memcpy(payloadStart, filename.c_str(), nameSize); std::memcpy(payloadStart, filename.c_str(), nameSize);
*(payloadStart + nameSize) = NULL_TERMINATOR; *(payloadStart + nameSize) = NULL_TERMINATOR;
return returnvalue::OK;
updateSpFields();
res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
return calcAndSetCrc();
} }
}; };
@@ -759,9 +760,8 @@ class TcGetDirContent : public TcBase {
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
std::memset(payloadStart, 0, 256);
std::memcpy(payloadStart, commandData, commandDataLen); std::memcpy(payloadStart, commandData, commandDataLen);
payloadStart[255] = 0; payloadStart[255] = '\0';
return result; return result;
} }
}; };
@@ -802,7 +802,7 @@ class TcReplayWriteSeq : public TcBase {
static const size_t USE_DECODING_LENGTH = 1; static const size_t USE_DECODING_LENGTH = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) { ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen > USE_DECODING_LENGTH + FILENAME_FIELD_SIZE or if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE or
checkPayloadLen() != returnvalue::OK) { checkPayloadLen() != returnvalue::OK) {
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen
<< std::endl; << std::endl;
@@ -821,18 +821,18 @@ class FlashBasePusCmd {
virtual ~FlashBasePusCmd() = default; virtual ~FlashBasePusCmd() = default;
virtual ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) { virtual ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > FILENAME_FIELD_SIZE) { if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
return INVALID_LENGTH; return INVALID_LENGTH;
} }
size_t fileLen = strnlen(reinterpret_cast<const char*>(commandData), commandDataLen); size_t fileLen = strnlen(reinterpret_cast<const char*>(commandData), commandDataLen);
if (fileLen > MAX_FILENAME_SIZE) { if (fileLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
return FILENAME_TOO_LONG; return FILENAME_TOO_LONG;
} }
obcFile = std::string(reinterpret_cast<const char*>(commandData), fileLen); obcFile = std::string(reinterpret_cast<const char*>(commandData), fileLen);
fileLen = fileLen =
strnlen(reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR), strnlen(reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR),
commandDataLen - obcFile.size() - 1); commandDataLen - obcFile.size() - 1);
if (fileLen > FILENAME_FIELD_SIZE) { if (fileLen > MAX_FILENAME_SIZE) {
return MPSOC_FILENAME_TOO_LONG; return MPSOC_FILENAME_TOO_LONG;
} }
mpsocFile = std::string( mpsocFile = std::string(
@@ -843,11 +843,11 @@ class FlashBasePusCmd {
const std::string& getObcFile() const { return obcFile; } const std::string& getObcFile() const { return obcFile; }
const std::string& getMpsocFile() const { return mpsocFile; } const std::string& getMPSoCFile() const { return mpsocFile; }
protected: protected:
size_t getParsedSize() const { size_t getParsedSize() const {
return getObcFile().size() + getMpsocFile().size() + 2 * SIZE_NULL_TERMINATOR; return getObcFile().size() + getMPSoCFile().size() + 2 * SIZE_NULL_TERMINATOR;
} }
static const size_t SIZE_NULL_TERMINATOR = 1; static const size_t SIZE_NULL_TERMINATOR = 1;
@@ -914,115 +914,24 @@ class TcCamTakePic : public TcBase {
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {} : TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
const uint8_t** dataPtr = &commandData; if (commandDataLen > MAX_DATA_LENGTH) {
if (commandDataLen > FULL_PAYLOAD_SIZE) {
return INVALID_LENGTH; return INVALID_LENGTH;
} }
size_t deserLen = commandDataLen; std::string fileName(reinterpret_cast<const char*>(commandData));
size_t serLen = 0; if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
fileName = reinterpret_cast<const char*>(commandData);
if (fileName.size() > MAX_FILENAME_SIZE) {
return FILENAME_TOO_LONG; return FILENAME_TOO_LONG;
} }
deserLen -= fileName.length() + 1; if (commandDataLen - (fileName.size() + sizeof(NULL_TERMINATOR)) != PARAMETER_SIZE) {
*dataPtr += fileName.length() + 1; return INVALID_LENGTH;
uint8_t** payloadPtr = &payloadStart;
memcpy(payloadStart, fileName.data(), fileName.size());
*payloadPtr += FILENAME_FIELD_SIZE;
serLen += FILENAME_FIELD_SIZE;
ReturnValue_t result = SerializeAdapter::deSerialize(&encoderSettingY, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
} }
result = SerializeAdapter::serialize(&encoderSettingY, payloadPtr, &serLen, FULL_PAYLOAD_SIZE, spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
SerializeIF::Endianness::NETWORK); std::memcpy(payloadStart, commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&quantizationY, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&quantizationY, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&encoderSettingsCb, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&encoderSettingsCb, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&quantizationCb, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&quantizationCb, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&encoderSettingsCr, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&encoderSettingsCr, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&quantizationCr, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&quantizationCr, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&bypassCompressor, dataPtr, &deserLen,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::serialize(&bypassCompressor, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
spParams.setFullPayloadLen(FULL_PAYLOAD_SIZE + CRC_SIZE);
return returnvalue::OK; return returnvalue::OK;
} }
std::string fileName;
uint8_t encoderSettingY = 7;
uint64_t quantizationY = 0;
uint8_t encoderSettingsCb = 7;
uint64_t quantizationCb = 0;
uint8_t encoderSettingsCr = 7;
uint64_t quantizationCr = 0;
uint8_t bypassCompressor = 0;
private: private:
static const size_t MAX_DATA_LENGTH = 286;
static const size_t PARAMETER_SIZE = 28; static const size_t PARAMETER_SIZE = 28;
static constexpr size_t FULL_PAYLOAD_SIZE = FILENAME_FIELD_SIZE + PARAMETER_SIZE;
}; };
/** /**
@@ -1034,31 +943,30 @@ class TcSimplexStreamFile : public TcBase {
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {} : TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > MAX_FILENAME_SIZE) { if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH; return INVALID_LENGTH;
} }
std::string fileName(reinterpret_cast<const char*>(commandData)); std::string fileName(reinterpret_cast<const char*>(commandData));
if (fileName.size() > MAX_FILENAME_SIZE) { if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
return FILENAME_TOO_LONG; return FILENAME_TOO_LONG;
} }
std::memset(payloadStart, 0, FILENAME_FIELD_SIZE);
std::memcpy(payloadStart, fileName.data(), fileName.length()); std::memcpy(payloadStart, fileName.data(), fileName.length());
payloadStart[fileName.length()] = 0; payloadStart[fileName.length()] = 0;
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE); spParams.setFullPayloadLen(fileName.length() + 1);
;
return returnvalue::OK; return returnvalue::OK;
} }
private: private:
static constexpr size_t MAX_DATA_LENGTH = 256;
}; };
/** /**
* @brief Class to build simplex send file command * @brief Class to build simplex send file command
*/ */
class TcSplitFile : public TcBase { class TcSimplexStoreFile : public TcBase {
public: public:
TcSplitFile(ploc::SpTcParams params, uint16_t sequenceCount) TcSimplexStoreFile(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {} : TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
@@ -1080,24 +988,29 @@ class TcSplitFile : public TcBase {
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
std::string fileName(reinterpret_cast<const char*>(*dataPtr)); std::string fileName(reinterpret_cast<const char*>(*dataPtr));
if (fileName.size() > MAX_FILENAME_SIZE) { if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
return FILENAME_TOO_LONG; return FILENAME_TOO_LONG;
} }
char divStr[16]{}; size_t currentCopyIdx = 0;
sprintf(divStr, "DIV%03u", chunkParameter); size_t payloadLen = fileName.length() + sizeof(NULL_TERMINATOR) + CRC_SIZE;
std::memcpy(payloadStart, divStr, DIV_STR_LEN); if (chunkParameter > 1) {
payloadStart[DIV_STR_LEN] = 0; char divStr[16]{};
std::memset(payloadStart + DIV_STR_LEN + 1, 0, FILENAME_FIELD_SIZE - DIV_STR_LEN - 1); sprintf(divStr, "DIV%03u", chunkParameter);
std::memcpy(payloadStart + DIV_STR_LEN + 1, fileName.data(), fileName.length()); std::memcpy(payloadStart, divStr, DIV_STR_LEN);
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE); payloadLen += DIV_STR_LEN;
currentCopyIdx += DIV_STR_LEN;
}
std::memcpy(payloadStart + currentCopyIdx, *dataPtr, fileName.length());
spParams.setFullPayloadLen(payloadLen);
return returnvalue::OK; return returnvalue::OK;
} }
private: private:
uint32_t chunkParameter = 0; uint32_t chunkParameter = 0;
static constexpr size_t MAX_DATA_LENGTH = 256;
static constexpr size_t MIN_DATA_LENGTH = 4; static constexpr size_t MIN_DATA_LENGTH = 4;
static constexpr size_t DIV_STR_LEN = 6; static constexpr size_t DIV_STR_LEN = 6;
static constexpr size_t MAX_DATA_LENGTH = 4 + MAX_FILENAME_SIZE;
}; };
/** /**

View File

@@ -232,7 +232,6 @@ void Guidance::targetRotationRate(const double timeDelta, double quatIX[4], doub
} }
if (timeDelta != 0.0) { if (timeDelta != 0.0) {
QuaternionOperations::rotationFromQuaternions(quatIX, quatIXprev, timeDelta, refSatRate); QuaternionOperations::rotationFromQuaternions(quatIX, quatIXprev, timeDelta, refSatRate);
VectorOperations<double>::mulScalar(refSatRate, -1, refSatRate, 3);
} else { } else {
std::memcpy(refSatRate, ZERO_VEC3, 3 * sizeof(double)); std::memcpy(refSatRate, ZERO_VEC3, 3 * sizeof(double));
} }
@@ -316,9 +315,9 @@ void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], do
// Calculate error satellite rotational rate // Calculate error satellite rotational rate
// Convert target rotational rate into body RF // Convert target rotational rate into body RF
double targetSatRotRateB[3] = {0, 0, 0}; double errorQuatInv[4] = {0, 0, 0, 0}, targetSatRotRateB[3] = {0, 0, 0};
QuaternionOperations::multiplyVector(currentQuat, targetSatRotRate, targetSatRotRateB); QuaternionOperations::inverse(errorQuat, errorQuatInv);
VectorOperations<double>::copy(targetSatRotRateB, targetSatRotRate, 3); QuaternionOperations::multiplyVector(errorQuatInv, targetSatRotRate, targetSatRotRateB);
// Combine the target and reference satellite rotational rates // Combine the target and reference satellite rotational rates
double combinedRefSatRotRate[3] = {0, 0, 0}; double combinedRefSatRotRate[3] = {0, 0, 0};
VectorOperations<double>::add(targetSatRotRate, refSatRotRate, combinedRefSatRotRate, 3); VectorOperations<double>::add(targetSatRotRate, refSatRotRate, combinedRefSatRotRate, 3);

View File

@@ -9,7 +9,7 @@ export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-li
export PATH=${CROSS_COMPILE_BIN_PATH}:$PATH export PATH=${CROSS_COMPILE_BIN_PATH}:$PATH
export CROSS_COMPILE="arm-linux-gnueabihf" export CROSS_COMPILE="arm-linux-gnueabihf"
unset EIVE_Q7S_EM # export EIVE_Q7S_EM=1
if [[ -d "eive-obsw" ]]; then if [[ -d "eive-obsw" ]]; then
echo "Detected EIVE OBSW root directory at $(pwd)/eive-obsw. Setting to EIVE_OBSW_ROOT" echo "Detected EIVE OBSW root directory at $(pwd)/eive-obsw. Setting to EIVE_OBSW_ROOT"

View File

@@ -4,9 +4,6 @@ import os
import sys import sys
DEFAULT_PORT = 1539
def main(): def main():
args = handle_args() args = handle_args()
cmd = build_cmd(args) cmd = build_cmd(args)
@@ -23,7 +20,7 @@ def prompt_ssh_key_removal():
do_remove_key = input( do_remove_key = input(
"Do you want to remove problematic keys on localhost ([Y]/n)?: " "Do you want to remove problematic keys on localhost ([Y]/n)?: "
) )
if do_remove_key.lower() not in ["y", "yes", "1", ""]: if not do_remove_key.lower() in ["y", "yes", "1", ""]:
sys.exit(1) sys.exit(1)
port = 0 port = 0
while True: while True:
@@ -57,7 +54,7 @@ def handle_args():
"If files are copied back to host, will be current directory by default", "If files are copied back to host, will be current directory by default",
default="", default="",
) )
parser.add_argument("-P", "--port", help="Target port", default=DEFAULT_PORT) parser.add_argument("-P", "--port", help="Target port", default=1535)
parser.add_argument( parser.add_argument(
"-i", "-i",
"--invert", "--invert",

2
tmtc

Submodule tmtc updated: 9a06c64dfa...dfa45dbdba