Compare commits

..

1 Commits

Author SHA1 Message Date
90d784a796 Rework MPSoC handler
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
2024-04-17 17:58:26 +02:00
31 changed files with 267 additions and 549 deletions

View File

@@ -16,33 +16,8 @@ will consitute of a breaking change warranting a new major release:
# [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
- 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
significantly.
- MPSoC device modes IDLE, SNAPSHOT and REPLAY are now modelled using submodes.
- Commanding a submode the device is already in will not result in a completion failure
anymore.
## Added
- Added `VERIFY_BOOT` command for MPSoC.
- New command for MPSoC to store camera image in chunks.
# [v7.8.1] 2024-04-11
## Fixed
- Reverted fix for wrong order in quaternion multiplication for computation of the error quaternion.
# [v7.8.0] 2024-04-10
@@ -53,7 +28,7 @@ will consitute of a breaking change warranting a new major release:
- All pointing laws are now allowed to use the `MEKF` per default.
- Changed limits in `PWR Controller`.
- 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.
- 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.
@@ -62,7 +37,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
missed.
- 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.
## Added
@@ -276,7 +251,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
on to the relevant mode functions. It handles all telemetry relevant functions, which were
always called, regardless of the mode.
## Added
- 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
* Generated on: 2024-05-06 13:47:38
* Generated on: 2024-04-17 11:22:10
*/
#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 *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
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_SPI_FAILURE_STRING = "SELF_TEST_SPI_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;
case (11608):
return SUPV_REPLY_TIMEOUT_STRING;
case (11609):
return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING;
case (11701):
return SELF_TEST_I2C_FAILURE_STRING;
case (11702):

View File

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

View File

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

View File

@@ -40,7 +40,7 @@
#include "mission/genericFactory.h"
#include "mission/system/acs/acsModeTree.h"
#include "mission/system/com/comModeTree.h"
#include "mission/system/payload/payloadModeTree.h"
#include "mission/system/payloadModeTree.h"
#include "mission/system/tcs/tcsModeTree.h"
#include "mission/tcs/defs.h"

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
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
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;SUPV reply timeout.;linux/payload/plocMpsocHelpers.h
11609;0x2d59;CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE;LOW;Camera must be commanded on first.;linux/payload/plocMpsocHelpers.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;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
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
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
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
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;SUPV reply timeout.;linux/payload/plocMpsocHelpers.h
11609;0x2d59;CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE;LOW;Camera must be commanded on first.;linux/payload/plocMpsocHelpers.h
11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;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
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
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
* Generated on: 2024-05-06 13:47:38
* Generated on: 2024-04-17 11:22:10
*/
#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 *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
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_SPI_FAILURE_STRING = "SELF_TEST_SPI_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;
case (11608):
return SUPV_REPLY_TIMEOUT_STRING;
case (11609):
return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING;
case (11701):
return SELF_TEST_I2C_FAILURE_STRING;
case (11702):

View File

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

View File

@@ -26,7 +26,7 @@
#include "devConf.h"
#include "devices/gpioIds.h"
#include "mission/system/acs/acsModeTree.h"
#include "mission/system/payload/payloadModeTree.h"
#include "mission/system/payloadModeTree.h"
#include "mission/system/power/epsModeTree.h"
void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF,

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
* Generated on: 2024-05-06 13:47:38
* Generated on: 2024-04-17 11:22:10
*/
#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 *SUPV_NOT_ON_STRING = "SUPV_NOT_ON";
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_SPI_FAILURE_STRING = "SELF_TEST_SPI_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;
case (11608):
return SUPV_REPLY_TIMEOUT_STRING;
case (11609):
return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING;
case (11701):
return SELF_TEST_I2C_FAILURE_STRING;
case (11702):

View File

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

View File

@@ -8,29 +8,22 @@
#include "fsfw/devicehandlers/FreshDeviceHandlerBase.h"
#include "fsfw/ipc/MessageQueueIF.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/serialize/SerializeAdapter.h"
#include "linux/payload/MpsocCommunication.h"
#include "linux/payload/plocMpsocHelpers.h"
#include "linux/payload/plocSupvDefs.h"
#include "mission/power/gsDefs.h"
FreshMpsocHandler::FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface,
PlocMpsocSpecialComHelper& specialComHelper,
Gpio uartIsolatorSwitch, object_id_t supervisorHandler,
PowerSwitchIF& powerSwitcher, power::Switch_t camSwitchId)
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
: FreshDeviceHandlerBase(cfg),
comInterface(comInterface),
specialComHelper(specialComHelper),
commandActionHelper(this),
uartIsolatorSwitch(uartIsolatorSwitch),
hkReport(this),
supervisorHandler(supervisorHandler),
powerSwitcher(powerSwitcher),
camSwitchId(camSwitchId) {
supervisorHandler(supervisorHandler) {
commandActionHelperQueue = QueueFactory::instance()->createMessageQueue(10);
eventQueue = QueueFactory::instance()->createMessageQueue(10);
spParams.maxSize = sizeof(commandBuffer);
@@ -45,7 +38,7 @@ void FreshMpsocHandler::performDeviceOperation(uint8_t opCode) {
if (opCode == OpCode::DEFAULT_OPERATION) {
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
// Linux UART RX buffer.
comInterface.readSerialInterface();
@@ -84,13 +77,8 @@ void FreshMpsocHandler::performDefaultDeviceOperation() {
}
}
// We checked the action queue beforehand, so action commands should always be performed
// before normal commands.
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 (mode == MODE_NORMAL and not activeCmdInfo.pending) {
// TODO: Take care of regular periodic commanding here.
}
if (activeCmdInfo.pending and activeCmdInfo.cmdCountdown.hasTimedOut()) {
@@ -165,6 +153,7 @@ ReturnValue_t FreshMpsocHandler::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
specialComHelper.setSequenceCount(&commandSequenceCount);
result = commandActionHelper.initialize();
if (result != returnvalue::OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
@@ -236,11 +225,6 @@ ReturnValue_t FreshMpsocHandler::checkModeCommand(Mode_t mode, Submode_t 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;
return returnvalue::OK;
}
@@ -281,11 +265,11 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
return result;
}
result = specialComHelper.startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMpsocFile());
flashWritePusCmd.getMPSoCFile());
if (result != returnvalue::OK) {
return result;
}
commonSpecialComInit();
specialComHelperExecuting = true;
return EXECUTION_FINISHED;
}
case mpsoc::TC_FLASH_READ_FULL_FILE: {
@@ -295,15 +279,12 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
return result;
}
result = specialComHelper.startFlashRead(flashReadPusCmd.getObcFile(),
flashReadPusCmd.getMpsocFile(),
flashReadPusCmd.getMPSoCFile(),
flashReadPusCmd.getReadSize());
if (result != returnvalue::OK) {
return result;
}
sif::info << "PLOC MPSoC: Reading " << flashReadPusCmd.getMpsocFile() << " with size "
<< flashReadPusCmd.getReadSize() << " to " << flashReadPusCmd.getObcFile()
<< std::endl;
commonSpecialComInit();
specialComHelperExecuting = true;
return EXECUTION_FINISHED;
}
case (mpsoc::OBSW_RESET_SEQ_COUNT_LEGACY): {
@@ -313,15 +294,12 @@ ReturnValue_t FreshMpsocHandler::executeAction(ActionId_t actionId, MessageQueue
default:
break;
}
// For longer commands, do not set these.
// TODO: Do all the stuff the form buildDeviceFromDevice blah did.
executeRegularCmd(actionId, commandedBy, data, size);
return returnvalue::OK;
}
void FreshMpsocHandler::commonSpecialComInit() {
specialComHelperExecuting = true;
specialComHelper.setCommandSequenceCount(commandSequenceCount.get());
}
/**
* @overload
* @param submode
@@ -337,10 +315,6 @@ void FreshMpsocHandler::startTransition(Mode_t newMode, Submode_t submode) {
} else if ((newMode == MODE_ON or newMode == MODE_NORMAL) &&
((mode == MODE_OFF) or (mode == MODE_UNDEFINED))) {
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) {
transitionState = TransitionState::TO_OFF;
}
@@ -376,9 +350,7 @@ void FreshMpsocHandler::handleTransitionToOn() {
if (startupState == StartupState::DONE) {
setMode(targetMode, targetSubmode);
transitionState = TransitionState::NONE;
if (targetMode == MODE_NORMAL) {
hkReport.setReportingEnabled(true);
}
hkReport.setReportingEnabled(true);
powerState = PowerState::IDLE;
startupState = StartupState::IDLE;
}
@@ -387,7 +359,7 @@ void FreshMpsocHandler::handleTransitionToOn() {
void FreshMpsocHandler::handleTransitionToOff() {
if (handleHwShutdown()) {
hkReport.setReportingEnabled(false);
setMode(MODE_OFF, 0);
setMode(MODE_OFF);
transitionState = TransitionState::NONE;
activeCmdInfo.reset();
powerState = PowerState::IDLE;
@@ -504,23 +476,6 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
result = commandTcMemRead(commandData, commandDataLen);
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): {
result = commandTcFlashDelete(commandData, commandDataLen);
break;
@@ -545,28 +500,6 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
result = commandTcReplayWriteSequence(commandData, commandDataLen);
break;
}
case (mpsoc::TC_ENABLE_TC_EXECTION): {
mpsoc::TcEnableTcExec cmd(spParams, commandSequenceCount);
result = cmd.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
result = finishAndSendTc(actionId, cmd);
break;
}
case (mpsoc::TC_FLASH_MKFS): {
if (commandDataLen != 1) {
return HasActionsIF::INVALID_PARAMETERS;
}
if (commandData[0] != mpsoc::FlashId::FLASH_0 && commandData[1] != mpsoc::FlashId::FLASH_1) {
return HasActionsIF::INVALID_PARAMETERS;
}
mpsoc::TcFlashMkfs cmd(spParams, commandSequenceCount,
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);
break;
}
case (mpsoc::TC_GET_HK_REPORT): {
result = commandTcGetHkReport();
break;
@@ -584,16 +517,9 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
break;
}
case (mpsoc::TC_SIMPLEX_STREAM_FILE): {
if (submode != mpsoc::Submode::SNAPSHOT) {
return HasModesIF::INVALID_SUBMODE;
}
result = commandTcSimplexStreamFile(commandData, commandDataLen);
break;
}
case (mpsoc::TC_SPLIT_FILE): {
result = commandTcSplitFile(commandData, commandDataLen);
break;
}
case (mpsoc::TC_DOWNLINK_DATA_MODULATE): {
result = commandTcDownlinkDataModulate(commandData, commandDataLen);
break;
@@ -606,20 +532,16 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId,
}
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;
}
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,
size_t commandDataLen) {
ReturnValue_t result = returnvalue::OK;
@@ -647,7 +569,7 @@ ReturnValue_t FreshMpsocHandler::commandTcMemRead(const uint8_t* commandData,
ReturnValue_t FreshMpsocHandler::commandTcFlashDelete(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen > mpsoc::FILENAME_FIELD_SIZE) {
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return mpsoc::NAME_TOO_LONG;
}
ReturnValue_t result = returnvalue::OK;
@@ -744,15 +666,6 @@ ReturnValue_t FreshMpsocHandler::commandTcCamTakePic(const uint8_t* commandData,
if (result != returnvalue::OK) {
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);
return returnvalue::OK;
}
@@ -768,14 +681,14 @@ ReturnValue_t FreshMpsocHandler::commandTcSimplexStreamFile(const uint8_t* comma
return returnvalue::OK;
}
ReturnValue_t FreshMpsocHandler::commandTcSplitFile(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcSplitFile tcSplitFile(spParams, commandSequenceCount);
ReturnValue_t result = tcSplitFile.setPayload(commandData, commandDataLen);
ReturnValue_t FreshMpsocHandler::commandTcSimplexStoreFile(const uint8_t* commandData,
size_t commandDataLen) {
mpsoc::TcSimplexStoreFile tcSimplexStoreFile(spParams, commandSequenceCount);
ReturnValue_t result = tcSimplexStoreFile.setPayload(commandData, commandDataLen);
if (result != returnvalue::OK) {
return result;
}
finishAndSendTc(mpsoc::TC_SPLIT_FILE, tcSplitFile);
finishAndSendTc(mpsoc::TC_SIMPLEX_STORE_FILE, tcSimplexStoreFile);
return returnvalue::OK;
}
@@ -807,21 +720,19 @@ ReturnValue_t FreshMpsocHandler::commandTcModeSnapshot() {
return returnvalue::OK;
}
ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc::TcBase& tcBase,
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 FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc::TcBase& tcBase) {
ReturnValue_t result = tcBase.finishPacket();
if (result != returnvalue::OK) {
return result;
}
// TODO: We should find a way so this works with the old implementation.
commandSequenceCount++;
mpsoc::printTxPacket(tcBase);
activeCmdInfo.cmdCountdown.setTimeout(cmdCountdownMs);
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.resetTimer();
activeCmdInfo.pending = true;
activeCmdInfo.pendingCmd = cmdId;
@@ -830,10 +741,11 @@ ReturnValue_t FreshMpsocHandler::finishAndSendTc(DeviceCommandId_t cmdId, mpsoc:
}
void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
// TODO: Shouldn't we check for specific events?
object_id_t objectId = eventMessage->getReporter();
switch (objectId) {
case objects::PLOC_MPSOC_HELPER: {
commonSpecialComStop();
case objects::PLOC_MPSOC_HANDLER: {
specialComHelperExecuting = false;
break;
}
default:
@@ -841,10 +753,6 @@ void FreshMpsocHandler::handleEvent(EventMessage* eventMessage) {
break;
}
}
void FreshMpsocHandler::commonSpecialComStop() {
specialComHelperExecuting = false;
commandSequenceCount.set(specialComHelper.getCommandSequenceCount());
}
void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
if (transitionState == TransitionState::SUBMODE) {
@@ -865,11 +773,17 @@ void FreshMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
ReturnValue_t result = returnvalue::OK;
const auto& replyReader = comInterface.getSpReader();
// SpacePacketReader spacePacket;
// spacePacket.setReadOnlyData(start, remainingSize);
auto& replyReader = comInterface.getSpReader();
if (replyReader.isNull()) {
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();
switch (apid) {
@@ -916,14 +830,15 @@ ReturnValue_t FreshMpsocHandler::handleDeviceReply() {
default: {
sif::debug << "FreshMpsocHandler:: Reply has invalid APID 0x" << std::hex << std::setfill('0')
<< std::setw(2) << apid << std::dec << std::endl;
//*foundLen = remainingSize;
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();
if (sequenceCount != lastReplySequenceCount + 1) {
// We could trigger event for possible missing reply packet to inform operator, but I don't
// think this is properly implemented and used on the MPSoC side anymore.
// TODO: Trigger event for possible missing reply packet to inform operator.
}
lastReplySequenceCount = sequenceCount;
@@ -978,6 +893,7 @@ ReturnValue_t FreshMpsocHandler::handleAckReport() {
switch (replyReader.getApid()) {
case mpsoc::apid::ACK_FAILURE: {
// DeviceCommandId_t commandId = getPendingCommand();
uint16_t status = mpsoc::getStatusFromRawData(replyReader.getFullData());
sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
triggerEvent(mpsoc::ACK_FAILURE, activeCmdInfo.pendingCmd, status);
@@ -1261,9 +1177,7 @@ bool FreshMpsocHandler::handleHwShutdown() {
supvTransitionCd.resetTimer();
powerState = PowerState::PENDING_SHUTDOWN;
} 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;
}
}

View File

@@ -1,4 +1,3 @@
#include "fsfw/action/ActionMessage.h"
#include "fsfw/action/CommandsActionsIF.h"
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
#include "fsfw/devicehandlers/FreshDeviceHandlerBase.h"
@@ -6,14 +5,15 @@
#include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/modes/ModeMessage.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/power/PowerSwitchIF.h"
#include "fsfw/power/definitions.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw_hal/linux/gpio/Gpio.h"
#include "linux/payload/MpsocCommunication.h"
#include "linux/payload/PlocMpsocSpecialComHelper.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 {
public:
enum OpCode { DEFAULT_OPERATION = 0, PARSE_TM = 1 };
@@ -21,8 +21,7 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface,
PlocMpsocSpecialComHelper& specialComHelper, Gpio uartIsolatorSwitch,
object_id_t supervisorHandler, PowerSwitchIF& powerSwitcher,
power::Switch_t camSwitchId);
object_id_t supervisorHandler);
/**
* Periodic helper executed function, implemented by child class.
@@ -98,7 +97,7 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
bool specialComHelperExecuting = false;
struct ActionCommandInfo {
Countdown cmdCountdown = Countdown(mpsoc::DEFAULT_CMD_TIMEOUT_MS);
Countdown cmdCountdown = Countdown(5000);
bool pending = false;
MessageQueueId_t commandedBy = MessageQueueIF::NO_QUEUE;
DeviceCommandId_t pendingCmd = DeviceHandlerIF::NO_COMMAND_ID;
@@ -132,8 +131,6 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
TmMemReadReport tmMemReadReport;
uint32_t lastReplySequenceCount = 0;
uint8_t skipSupvCommandingToOn = false;
PowerSwitchIF& powerSwitcher;
power::Switch_t camSwitchId;
// HK manager abstract functions.
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
@@ -187,12 +184,11 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
ReturnValue_t commandTcModeIdle();
ReturnValue_t commandTcCamTakePic(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 commandTcModeSnapshot();
ReturnValue_t finishAndSendTc(DeviceCommandId_t cmdId, mpsoc::TcBase& tcBase,
uint32_t cmdCountdown = mpsoc::DEFAULT_CMD_TIMEOUT_MS);
ReturnValue_t finishAndSendTc(DeviceCommandId_t cmdId, mpsoc::TcBase& tcBase);
void handleEvent(EventMessage* eventMessage);
void cmdDoneHandler(bool success, ReturnValue_t result);
ReturnValue_t handleDeviceReply();
@@ -206,7 +202,4 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI
void stopSpecialComHelper();
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::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);
}
@@ -30,7 +27,7 @@ ReturnValue_t MpsocCommunication::parseAndRetrieveNextPacket() {
return returnvalue::OK;
}
readRingBuf.readData(readBuf, availableReadData);
spReader.setReadOnlyData(readBuf, sizeof(readBuf));
spReader.setReadOnlyData(readBuf, availableReadData);
auto res = spReader.checkSize();
if (res != returnvalue::OK) {
return res;

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,5 @@
#include "plocMpsocHelpers.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "mission/payload/plocSpBase.h"
uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) {
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
}
@@ -16,10 +13,6 @@ std::string mpsoc::getStatusString(uint16_t status) {
return "Incorrect length";
break;
}
case (mpsoc::statusCode::FLASH_DRIVE_ERROR): {
return "flash drive error";
break;
}
case (mpsoc::statusCode::INCORRECT_CRC): {
return "Incorrect crc";
break;
@@ -100,19 +93,3 @@ std::string mpsoc::getStatusString(uint16_t status) {
}
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,66 +5,15 @@
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <mission/payload/plocSpBase.h>
#include "eive/definitions.h"
#include "eive/eventSubsystemIds.h"
#include "eive/resultClassIds.h"
#include "fsfw/action/HasActionsIF.h"
#include "fsfw/events/Event.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serialize/SerializeIF.h"
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 CMD_TIMEOUT_MKFS = 15000;
enum FlashId : uint8_t { FLASH_0 = 0, FLASH_1 = 1 };
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF;
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
@@ -113,11 +62,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
//! ON transition.
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);
//! [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 };
@@ -210,16 +155,16 @@ static const DeviceCommandId_t TC_FLASH_GET_DIRECTORY_CONTENT = 28;
static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29;
static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30;
// 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_ENABLE_TC_EXECTION = 33;
static const DeviceCommandId_t TC_FLASH_MKFS = 34;
// Will reset the sequence count of the OBSW. Not required anymore after MPSoC update.
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT_LEGACY = 50;
static const uint16_t SIZE_ACK_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;
enum Submode : uint8_t { IDLE_OR_NONE = 0, REPLAY = 1, SNAPSHOT = 2 };
@@ -258,8 +203,6 @@ static const uint16_t TC_MODE_SNAPSHOT = 0x120;
static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121;
static constexpr uint16_t TC_HK_GET_REPORT = 0x123;
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
static constexpr uint16_t TC_ENABLE_TC_EXECUTION = 0x129;
static constexpr uint16_t TC_FLASH_MKFS = 0x12A;
static const uint16_t TC_CAM_CMD_SEND = 0x12C;
static constexpr uint16_t TC_FLASH_COPY_FILE = 0x12E;
static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130;
@@ -284,15 +227,15 @@ static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
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
* 8.
*/
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
static const size_t FILENAME_FIELD_SIZE = 256;
// Subtract size of NULL terminator.
static const size_t MAX_FILENAME_SIZE = FILENAME_FIELD_SIZE - 1;
static const size_t MAX_FILENAME_SIZE = 256;
/**
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
@@ -329,7 +272,6 @@ static const uint16_t TC_SIMPLEX_SEND_FILE_DELAY = 80;
namespace statusCode {
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 INCORRECT_LENGTH = 0x5DE;
static const uint16_t INCORRECT_CRC = 0x5DF;
@@ -356,10 +298,47 @@ static const uint16_t RESERVED_3 = 0x5F3;
static const uint16_t RESERVED_4 = 0x5F4;
} // 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.
*/
class TcMemRead : public mpsoc::TcBase {
class TcMemRead : public TcBase {
public:
/**
* @brief Constructor
@@ -409,7 +388,7 @@ class TcMemRead : public mpsoc::TcBase {
* @brief This class helps to generate the space packet to write data to a memory address within
* the PLOC.
*/
class TcMemWrite : public mpsoc::TcBase {
class TcMemWrite : public TcBase {
public:
/**
* @brief Constructor
@@ -459,21 +438,24 @@ class TcMemWrite : public mpsoc::TcBase {
/**
* @brief Class to help creation of flash fopen command.
*/
class TcFlashFopen : public mpsoc::TcBase {
class FlashFopen : public TcBase {
public:
TcFlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
ReturnValue_t setPayload(std::string filename, uint8_t mode) {
accessMode = mode;
size_t nameSize = filename.size();
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
ReturnValue_t result = checkPayloadLen();
if (result != returnvalue::OK) {
return result;
}
std::memset(payloadStart, 0, FILENAME_FIELD_SIZE);
std::memcpy(payloadStart, filename.c_str(), filename.size());
payloadStart[FILENAME_FIELD_SIZE] = accessMode;
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + 1 + CRC_SIZE);
std::memcpy(payloadStart, filename.c_str(), nameSize);
// payloadStart[nameSize] = NULL_TERMINATOR;
std::memset(payloadStart + nameSize, 0, 256 - nameSize);
// payloadStart[255] = NULL_TERMINATOR;
payloadStart[256] = accessMode;
return returnvalue::OK;
}
@@ -484,46 +466,14 @@ class TcFlashFopen : public mpsoc::TcBase {
/**
* @brief Class to help creation of flash fclose command.
*/
class TcFlashFclose : public TcBase {
class FlashFclose : public TcBase {
public:
TcFlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {
spParams.setFullPayloadLen(CRC_SIZE);
}
};
class TcEnableTcExec : public TcBase {
public:
TcEnableTcExec(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_ENABLE_TC_EXECUTION, sequenceCount) {
spParams.setFullPayloadLen(CRC_SIZE);
}
ReturnValue_t setPayload(const uint8_t* cmdData, size_t cmdDataLen) {
if (cmdDataLen != 2) {
return HasActionsIF::INVALID_PARAMETERS;
}
std::memcpy(payloadStart, cmdData, 2);
spParams.setFullPayloadLen(2 + CRC_SIZE);
return returnvalue::OK;
}
};
class TcFlashMkfs : public TcBase {
public:
TcFlashMkfs(ploc::SpTcParams params, uint16_t sequenceCount, FlashId flashId)
: TcBase(params, apid::TC_FLASH_MKFS, sequenceCount) {
const char* flashIdStr = "0:\\";
if (flashId == FlashId::FLASH_1) {
flashIdStr = "1:\\";
}
std::memcpy(payloadStart, flashIdStr, 3);
// Null terminator
payloadStart[3] = 0;
spParams.setFullPayloadLen(4 + CRC_SIZE);
}
};
/**
* @brief Class to build flash write space packet.
*/
@@ -583,6 +533,15 @@ class TcFlashRead : public TcBase {
if (result != returnvalue::OK) {
return result;
}
updateSpFields();
result = checkSizeAndSerializeHeader();
if (result != returnvalue::OK) {
return result;
}
result = calcAndSetCrc();
if (result != returnvalue::OK) {
return result;
}
readSize = readLen;
return result;
}
@@ -600,14 +559,20 @@ class TcFlashDelete : public TcBase {
ReturnValue_t setPayload(std::string filename) {
size_t nameSize = filename.size();
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE);
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
auto res = checkPayloadLen();
if (res != returnvalue::OK) {
return res;
}
std::memcpy(payloadStart, filename.c_str(), nameSize);
*(payloadStart + nameSize) = NULL_TERMINATOR;
return returnvalue::OK;
updateSpFields();
res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
return calcAndSetCrc();
}
};
@@ -759,9 +724,8 @@ class TcGetDirContent : public TcBase {
if (result != returnvalue::OK) {
return result;
}
std::memset(payloadStart, 0, 256);
std::memcpy(payloadStart, commandData, commandDataLen);
payloadStart[255] = 0;
payloadStart[255] = '\0';
return result;
}
};
@@ -802,7 +766,7 @@ class TcReplayWriteSeq : public TcBase {
static const size_t USE_DECODING_LENGTH = 1;
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) {
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen
<< std::endl;
@@ -821,18 +785,18 @@ class FlashBasePusCmd {
virtual ~FlashBasePusCmd() = default;
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;
}
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;
}
obcFile = std::string(reinterpret_cast<const char*>(commandData), fileLen);
fileLen =
strnlen(reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR),
commandDataLen - obcFile.size() - 1);
if (fileLen > FILENAME_FIELD_SIZE) {
if (fileLen > MAX_FILENAME_SIZE) {
return MPSOC_FILENAME_TOO_LONG;
}
mpsocFile = std::string(
@@ -843,11 +807,11 @@ class FlashBasePusCmd {
const std::string& getObcFile() const { return obcFile; }
const std::string& getMpsocFile() const { return mpsocFile; }
const std::string& getMPSoCFile() const { return mpsocFile; }
protected:
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;
@@ -914,115 +878,24 @@ class TcCamTakePic : public TcBase {
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
const uint8_t** dataPtr = &commandData;
if (commandDataLen > FULL_PAYLOAD_SIZE) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
size_t deserLen = commandDataLen;
size_t serLen = 0;
fileName = reinterpret_cast<const char*>(commandData);
if (fileName.size() > MAX_FILENAME_SIZE) {
std::string fileName(reinterpret_cast<const char*>(commandData));
if (fileName.size() + sizeof(NULL_TERMINATOR) > MAX_FILENAME_SIZE) {
return FILENAME_TOO_LONG;
}
deserLen -= fileName.length() + 1;
*dataPtr += fileName.length() + 1;
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;
if (commandDataLen - (fileName.size() + sizeof(NULL_TERMINATOR)) != PARAMETER_SIZE) {
return INVALID_LENGTH;
}
result = SerializeAdapter::serialize(&encoderSettingY, payloadPtr, &serLen, FULL_PAYLOAD_SIZE,
SerializeIF::Endianness::NETWORK);
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);
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
std::memcpy(payloadStart, commandData, commandDataLen);
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:
static const size_t MAX_DATA_LENGTH = 286;
static const size_t PARAMETER_SIZE = 28;
static constexpr size_t FULL_PAYLOAD_SIZE = FILENAME_FIELD_SIZE + PARAMETER_SIZE;
};
/**
@@ -1034,31 +907,30 @@ class TcSimplexStreamFile : public TcBase {
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > MAX_FILENAME_SIZE) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
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;
}
std::memset(payloadStart, 0, FILENAME_FIELD_SIZE);
std::memcpy(payloadStart, fileName.data(), fileName.length());
payloadStart[fileName.length()] = 0;
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE);
;
spParams.setFullPayloadLen(fileName.length() + 1);
return returnvalue::OK;
}
private:
static constexpr size_t MAX_DATA_LENGTH = 256;
};
/**
* @brief Class to build simplex send file command
*/
class TcSplitFile : public TcBase {
class TcSimplexStoreFile : public TcBase {
public:
TcSplitFile(ploc::SpTcParams params, uint16_t sequenceCount)
TcSimplexStoreFile(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
@@ -1080,24 +952,29 @@ class TcSplitFile : public TcBase {
return INVALID_PARAMETER;
}
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;
}
char divStr[16]{};
sprintf(divStr, "DIV%03u", chunkParameter);
std::memcpy(payloadStart, divStr, DIV_STR_LEN);
payloadStart[DIV_STR_LEN] = 0;
std::memset(payloadStart + DIV_STR_LEN + 1, 0, FILENAME_FIELD_SIZE - DIV_STR_LEN - 1);
std::memcpy(payloadStart + DIV_STR_LEN + 1, fileName.data(), fileName.length());
spParams.setFullPayloadLen(FILENAME_FIELD_SIZE + CRC_SIZE);
size_t currentCopyIdx = 0;
size_t payloadLen = fileName.length() + sizeof(NULL_TERMINATOR) + CRC_SIZE;
if (chunkParameter > 1) {
char divStr[16]{};
sprintf(divStr, "DIV%03u", chunkParameter);
std::memcpy(payloadStart, divStr, DIV_STR_LEN);
payloadLen += DIV_STR_LEN;
currentCopyIdx += DIV_STR_LEN;
}
std::memcpy(payloadStart + currentCopyIdx, *dataPtr, fileName.length());
spParams.setFullPayloadLen(payloadLen);
return returnvalue::OK;
}
private:
uint32_t chunkParameter = 0;
static constexpr size_t MAX_DATA_LENGTH = 256;
static constexpr size_t MIN_DATA_LENGTH = 4;
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) {
QuaternionOperations::rotationFromQuaternions(quatIX, quatIXprev, timeDelta, refSatRate);
VectorOperations<double>::mulScalar(refSatRate, -1, refSatRate, 3);
} else {
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
// Convert target rotational rate into body RF
double targetSatRotRateB[3] = {0, 0, 0};
QuaternionOperations::multiplyVector(currentQuat, targetSatRotRate, targetSatRotRateB);
VectorOperations<double>::copy(targetSatRotRateB, targetSatRotRate, 3);
double errorQuatInv[4] = {0, 0, 0, 0}, targetSatRotRateB[3] = {0, 0, 0};
QuaternionOperations::inverse(errorQuat, errorQuatInv);
QuaternionOperations::multiplyVector(errorQuatInv, targetSatRotRate, targetSatRotRateB);
// Combine the target and reference satellite rotational rates
double combinedRefSatRotRate[3] = {0, 0, 0};
VectorOperations<double>::add(targetSatRotRate, refSatRotRate, combinedRefSatRotRate, 3);

View File

@@ -3,9 +3,8 @@ add_subdirectory(acs)
add_subdirectory(tcs)
add_subdirectory(com)
add_subdirectory(power)
add_subdirectory(payload)
target_sources(
${LIB_EIVE_MISSION}
PRIVATE systemTree.cpp DualLanePowerStateMachine.cpp EiveSystem.cpp
treeUtil.cpp SharedPowerAssemblyBase.cpp)
treeUtil.cpp SharedPowerAssemblyBase.cpp payloadModeTree.cpp)

View File

@@ -1 +0,0 @@
target_sources(${LIB_EIVE_MISSION} PRIVATE payloadModeTree.cpp)

View File

@@ -10,7 +10,7 @@
#include "mission/com/defs.h"
#include "mission/sysDefs.h"
#include "mission/system/acs/acsModeTree.h"
#include "mission/system/payload/payloadModeTree.h"
#include "mission/system/payloadModeTree.h"
#include "mission/system/power/epsModeTree.h"
#include "mission/system/tcs/tcsModeTree.h"
#include "treeUtil.h"

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 CROSS_COMPILE="arm-linux-gnueabihf"
unset EIVE_Q7S_EM
# export EIVE_Q7S_EM=1
if [[ -d "eive-obsw" ]]; then
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
DEFAULT_PORT = 1539
def main():
args = handle_args()
cmd = build_cmd(args)
@@ -23,7 +20,7 @@ def prompt_ssh_key_removal():
do_remove_key = input(
"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)
port = 0
while True:
@@ -57,7 +54,7 @@ def handle_args():
"If files are copied back to host, will be current directory by 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(
"-i",
"--invert",

2
tmtc

Submodule tmtc updated: 9a06c64dfa...69fda96d7a