Merge branch 'v2.2.0-dev' into update-ptme-code-2
All checks were successful
EIVE/eive-obsw/pipeline/pr-v2.2.0-dev This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-v2.2.0-dev This commit looks good
This commit is contained in:
commit
8efbdf8279
11
CHANGELOG.md
11
CHANGELOG.md
@ -48,11 +48,19 @@ TODO: New firmware package version.
|
||||
- Add support for MPSoC HK packet.
|
||||
- Add support for MPSoC Flash Directory Content Report.
|
||||
- Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands.
|
||||
- Add support for MPSoC Flash Directory Content Report.
|
||||
- Larger allowed path and file sizes for STR and PLOC MPSoC modules.
|
||||
- More robust MPSoC flash read and write command data handling.
|
||||
- Increase frequency of payload handlers from 0.8 seconds to 0.5 seconds.
|
||||
- Disable missed deadlines per default. Not useful in orbit, and triggers all the time on the EM
|
||||
build after a number of subsequent runs, without any apparent reason (deadlines are not actually
|
||||
missed, thread usage displayed is nominal)
|
||||
|
||||
## Added
|
||||
|
||||
- Add the remaining system modes.
|
||||
- PLOC MPSoC flash read command working.
|
||||
- BPX battery handler is added for EM by default.
|
||||
|
||||
## Fixed
|
||||
|
||||
@ -69,6 +77,9 @@ TODO: New firmware package version.
|
||||
- The PLOC MPSoC now waits 10 cycles before going to on. These wait cycles are necessary because
|
||||
the MPSoC is not ready to process commands without this additional boot time.
|
||||
- Fixed correction for `GPS Altitude` in case the sensor data is out of the expected bonds.
|
||||
- PLOC MPSoC special communication is now scheduled, which allows flash read and flash write
|
||||
commands to work.
|
||||
- Fixed the MPSoC flash write command.
|
||||
|
||||
# [v2.0.5] 2023-05-11
|
||||
|
||||
|
@ -83,8 +83,8 @@ set(OBSW_ADD_MGT
|
||||
${INIT_VAL}
|
||||
CACHE STRING "Add MGT module")
|
||||
set(OBSW_ADD_BPX_BATTERY_HANDLER
|
||||
${INIT_VAL}
|
||||
CACHE STRING "Add MGT module")
|
||||
1
|
||||
CACHE STRING "Add BPX battery module")
|
||||
set(OBSW_ADD_STAR_TRACKER
|
||||
${INIT_VAL}
|
||||
CACHE STRING "Add Startracker module")
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "devices/gpioIds.h"
|
||||
#include "fsfw_hal/linux/gpio/Gpio.h"
|
||||
#include "linux/payload/PlocMpsocHandler.h"
|
||||
#include "linux/payload/PlocMpsocHelper.h"
|
||||
#include "linux/payload/PlocMpsocSpecialComHelper.h"
|
||||
#include "linux/payload/PlocSupervisorHandler.h"
|
||||
#include "linux/payload/PlocSupvUartMan.h"
|
||||
#include "test/gpio/DummyGpioIF.h"
|
||||
@ -82,8 +82,8 @@ void ObjectFactory::produce(void* args) {
|
||||
auto mpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, mpscoDev, uart::PLOC_MPSOC_BAUD,
|
||||
mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL);
|
||||
mpsocCookie->setNoFixedSizeReply();
|
||||
auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
|
||||
new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie,
|
||||
auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER);
|
||||
new PlocMpsocHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie,
|
||||
plocMpsocHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, dummyGpioIF),
|
||||
objects::PLOC_SUPERVISOR_HANDLER);
|
||||
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @brief Auto-generated event translation file. Contains 291 translations.
|
||||
* @brief Auto-generated event translation file. Contains 295 translations.
|
||||
* @details
|
||||
* Generated on: 2023-04-17 11:34:19
|
||||
* Generated on: 2023-05-17 17:15:34
|
||||
*/
|
||||
#include "translateEvents.h"
|
||||
|
||||
@ -197,6 +197,10 @@ const char *MPSOC_EXE_INVALID_APID_STRING = "MPSOC_EXE_INVALID_APID";
|
||||
const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH";
|
||||
const char *MPSOC_TM_SIZE_ERROR_STRING = "MPSOC_TM_SIZE_ERROR";
|
||||
const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH";
|
||||
const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR";
|
||||
const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED";
|
||||
const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL";
|
||||
const char *MPSOC_READ_TIMEOUT_STRING = "MPSOC_READ_TIMEOUT";
|
||||
const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF";
|
||||
const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS";
|
||||
const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS";
|
||||
@ -683,6 +687,14 @@ const char *translateEvents(Event event) {
|
||||
return MPSOC_TM_SIZE_ERROR_STRING;
|
||||
case (12613):
|
||||
return MPSOC_TM_CRC_MISSMATCH_STRING;
|
||||
case (12614):
|
||||
return MPSOC_FLASH_READ_PACKET_ERROR_STRING;
|
||||
case (12615):
|
||||
return MPSOC_FLASH_READ_FAILED_STRING;
|
||||
case (12616):
|
||||
return MPSOC_FLASH_READ_SUCCESSFUL_STRING;
|
||||
case (12617):
|
||||
return MPSOC_READ_TIMEOUT_STRING;
|
||||
case (12700):
|
||||
return TRANSITION_BACK_TO_OFF_STRING;
|
||||
case (12701):
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @brief Auto-generated object translation file.
|
||||
* @details
|
||||
* Contains 171 translations.
|
||||
* Generated on: 2023-04-17 11:34:19
|
||||
* Generated on: 2023-05-17 17:15:34
|
||||
*/
|
||||
#include "translateObjects.h"
|
||||
|
||||
|
@ -72,7 +72,7 @@
|
||||
|
||||
// Can be used to switch device to NORMAL mode immediately
|
||||
#define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 0
|
||||
#define OBSW_PRINT_MISSED_DEADLINES 1
|
||||
#define OBSW_PRINT_MISSED_DEADLINES 0
|
||||
|
||||
#define OBSW_MPSOC_JTAG_BOOT 0
|
||||
#define OBSW_STAR_TRACKER_GROUND_CONFIG @OBSW_STAR_TRACKER_GROUND_CONFIG@
|
||||
|
@ -10,10 +10,10 @@
|
||||
#include <linux/com/SyrlinksComHandler.h>
|
||||
#include <linux/payload/PlocMemoryDumper.h>
|
||||
#include <linux/payload/PlocMpsocHandler.h>
|
||||
#include <linux/payload/PlocMpsocHelper.h>
|
||||
#include <linux/payload/PlocMpsocSpecialComHelper.h>
|
||||
#include <linux/payload/PlocSupervisorHandler.h>
|
||||
#include <linux/payload/ScexUartReader.h>
|
||||
#include <linux/payload/plocMpscoDefs.h>
|
||||
#include <linux/payload/plocMpsocHelpers.h>
|
||||
#include <linux/power/CspComIF.h>
|
||||
#include <mission/acs/GyrL3gCustomHandler.h>
|
||||
#include <mission/acs/MgmLis3CustomHandler.h>
|
||||
@ -623,8 +623,8 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit
|
||||
new SerialCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV,
|
||||
serial::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE, UartModes::NON_CANONICAL);
|
||||
mpsocCookie->setNoFixedSizeReply();
|
||||
auto plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
|
||||
auto* mpsocHandler = new PlocMPSoCHandler(
|
||||
auto plocMpsocHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER);
|
||||
auto* mpsocHandler = new PlocMpsocHandler(
|
||||
objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, mpsocCookie, plocMpsocHelper,
|
||||
Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), objects::PLOC_SUPERVISOR_HANDLER);
|
||||
mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM);
|
||||
|
@ -345,7 +345,6 @@ void scheduling::initTasks() {
|
||||
}
|
||||
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
||||
|
||||
// TODO: Use regular scheduler for this task
|
||||
#if OBSW_ADD_PLOC_MPSOC == 1
|
||||
PeriodicTaskIF* mpsocHelperTask = factory->createPeriodicTask(
|
||||
"PLOC_MPSOC_HELPER", 0, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
||||
@ -472,6 +471,9 @@ void scheduling::initTasks() {
|
||||
#if OBSW_ADD_PLOC_SUPERVISOR == 1
|
||||
supvHelperTask->startTask();
|
||||
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
|
||||
#if OBSW_ADD_PLOC_MPSOC == 1
|
||||
mpsocHelperTask->startTask();
|
||||
#endif
|
||||
plTask->startTask();
|
||||
|
||||
#if OBSW_ADD_TEST_CODE == 1
|
||||
|
@ -34,8 +34,8 @@ static constexpr uint32_t STR_IMG_HELPER_QUEUE_SIZE = 50;
|
||||
static constexpr uint8_t LIVE_TM = 0;
|
||||
|
||||
/* Limits for filename and path checks */
|
||||
static constexpr uint32_t MAX_PATH_SIZE = 100;
|
||||
static constexpr uint32_t MAX_FILENAME_SIZE = 50;
|
||||
static constexpr uint32_t MAX_PATH_SIZE = 200;
|
||||
static constexpr uint32_t MAX_FILENAME_SIZE = 100;
|
||||
|
||||
static constexpr uint32_t SA_DEPL_INIT_BUFFER_SECS = 120;
|
||||
// Burn time for autonomous deployment
|
||||
|
@ -177,20 +177,24 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
|
||||
12515;0x30e3;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not exist P1: Internal state of str helper;linux/acs/StrComHandler.h
|
||||
12516;0x30e4;STR_HELPER_SENDING_PACKET_FAILED;LOW;No description;linux/acs/StrComHandler.h
|
||||
12517;0x30e5;STR_HELPER_REQUESTING_MSG_FAILED;LOW;No description;linux/acs/StrComHandler.h
|
||||
12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocHelper.h
|
||||
12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;LOW;Flash write successful;linux/payload/PlocMpsocHelper.h
|
||||
12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocHelper.h
|
||||
12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHelper.h
|
||||
12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocHelper.h
|
||||
12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocHelper.h
|
||||
12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;INFO;Flash write successful;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12617;0x3149;MPSOC_READ_TIMEOUT;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h
|
||||
12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h
|
||||
12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h
|
||||
@ -274,7 +278,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
|
||||
14105;0x3719;CAMERA_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||
14106;0x371a;PCDU_SYSTEM_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||
14107;0x371b;HEATER_NOT_OFF_FOR_OFF_MODE;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||
14108;0x371c;MGT_OVERHEATING;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||
14108;0x371c;MGT_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||
14201;0x3779;TX_TIMER_EXPIRED;INFO;The transmit timer to protect the Syrlinks expired P1: The current timer value;mission/system/com/ComSubsystem.h
|
||||
14202;0x377a;BIT_LOCK_TX_ON;INFO;Transmitter will be turned on due to detection of bitlock;mission/system/com/ComSubsystem.h
|
||||
14300;0x37dc;POSSIBLE_FILE_CORRUPTION;LOW;P1: Result code of TM packet parser. P2: Timestamp of possibly corrupt file as a unix timestamp.;mission/persistentTmStoreDefs.h
|
||||
|
|
@ -177,20 +177,24 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
|
||||
12515;0x30e3;STR_HELPER_FILE_NOT_EXISTS;LOW;Specified file does not exist P1: Internal state of str helper;linux/acs/StrComHandler.h
|
||||
12516;0x30e4;STR_HELPER_SENDING_PACKET_FAILED;LOW;No description;linux/acs/StrComHandler.h
|
||||
12517;0x30e5;STR_HELPER_REQUESTING_MSG_FAILED;LOW;No description;linux/acs/StrComHandler.h
|
||||
12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocHelper.h
|
||||
12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;LOW;Flash write successful;linux/payload/PlocMpsocHelper.h
|
||||
12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocHelper.h
|
||||
12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocHelper.h
|
||||
12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocHelper.h
|
||||
12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocHelper.h
|
||||
12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocHelper.h
|
||||
12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocHelper.h
|
||||
12600;0x3138;MPSOC_FLASH_WRITE_FAILED;LOW;Flash write fails;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12601;0x3139;MPSOC_FLASH_WRITE_SUCCESSFUL;INFO;Flash write successful;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12602;0x313a;MPSOC_SENDING_COMMAND_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12603;0x313b;MPSOC_HELPER_REQUESTING_REPLY_FAILED;LOW;Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12604;0x313c;MPSOC_HELPER_READING_REPLY_FAILED;LOW;Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12605;0x313d;MPSOC_MISSING_ACK;LOW;Did not receive acknowledgment report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12606;0x313e;MPSOC_MISSING_EXE;LOW;Did not receive execution report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12607;0x313f;MPSOC_ACK_FAILURE_REPORT;LOW;Received acknowledgment failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12608;0x3140;MPSOC_EXE_FAILURE_REPORT;LOW;Received execution failure report P1: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12609;0x3141;MPSOC_ACK_INVALID_APID;LOW;Expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12610;0x3142;MPSOC_EXE_INVALID_APID;LOW;Expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of MPSoC;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12611;0x3143;MPSOC_HELPER_SEQ_CNT_MISMATCH;LOW;Received sequence count does not match expected sequence count P1: Expected sequence count P2: Received sequence count;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12612;0x3144;MPSOC_TM_SIZE_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12613;0x3145;MPSOC_TM_CRC_MISSMATCH;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12614;0x3146;MPSOC_FLASH_READ_PACKET_ERROR;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12615;0x3147;MPSOC_FLASH_READ_FAILED;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12616;0x3148;MPSOC_FLASH_READ_SUCCESSFUL;INFO;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12617;0x3149;MPSOC_READ_TIMEOUT;LOW;No description;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
12700;0x319c;TRANSITION_BACK_TO_OFF;MEDIUM;Could not transition properly and went back to ALL OFF;mission/payload/PayloadPcduHandler.h
|
||||
12701;0x319d;NEG_V_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h
|
||||
12702;0x319e;U_DRO_OUT_OF_BOUNDS;MEDIUM;P1: 0 -> too low, 1 -> too high P2: Float value;mission/payload/PayloadPcduHandler.h
|
||||
@ -274,7 +278,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
|
||||
14105;0x3719;CAMERA_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||
14106;0x371a;PCDU_SYSTEM_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||
14107;0x371b;HEATER_NOT_OFF_FOR_OFF_MODE;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||
14108;0x371c;MGT_OVERHEATING;MEDIUM;No description;mission/controller/tcsDefs.h
|
||||
14108;0x371c;MGT_OVERHEATING;HIGH;No description;mission/controller/tcsDefs.h
|
||||
14201;0x3779;TX_TIMER_EXPIRED;INFO;The transmit timer to protect the Syrlinks expired P1: The current timer value;mission/system/com/ComSubsystem.h
|
||||
14202;0x377a;BIT_LOCK_TX_ON;INFO;Transmitter will be turned on due to detection of bitlock;mission/system/com/ComSubsystem.h
|
||||
14300;0x37dc;POSSIBLE_FILE_CORRUPTION;LOW;P1: Result code of TM packet parser. P2: Timestamp of possibly corrupt file as a unix timestamp.;mission/persistentTmStoreDefs.h
|
||||
|
|
@ -478,8 +478,8 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
|
||||
0x53b6;STRH_StartrackerAlreadyBooted;Star tracker is already in firmware mode;182;STR_HANDLER;mission/acs/str/StarTrackerHandler.h
|
||||
0x53b7;STRH_StartrackerNotRunningFirmware;Star tracker must be in firmware mode to run this command;183;STR_HANDLER;mission/acs/str/StarTrackerHandler.h
|
||||
0x53b8;STRH_StartrackerNotRunningBootloader;Star tracker must be in bootloader mode to run this command;184;STR_HANDLER;mission/acs/str/StarTrackerHandler.h
|
||||
0x54e0;DWLPWRON_InvalidMode;Received command has invalid JESD mode (valid modes are 0 - 5);224;DWLPWRON_CMD;linux/payload/plocMpscoDefs.h
|
||||
0x54e1;DWLPWRON_InvalidLaneRate;Received command has invalid lane rate (valid lane rate are 0 - 9);225;DWLPWRON_CMD;linux/payload/plocMpscoDefs.h
|
||||
0x54e0;DWLPWRON_InvalidMode;Received command has invalid JESD mode (valid modes are 0 - 5);224;DWLPWRON_CMD;linux/payload/plocMpsocHelpers.h
|
||||
0x54e1;DWLPWRON_InvalidLaneRate;Received command has invalid lane rate (valid lane rate are 0 - 9);225;DWLPWRON_CMD;linux/payload/plocMpsocHelpers.h
|
||||
0x5700;PLSPVhLP_RequestDone;No description;0;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h
|
||||
0x5701;PLSPVhLP_NoPacketFound;No description;1;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h
|
||||
0x5702;PLSPVhLP_DecodeBufTooSmall;No description;2;PLOC_SUPV_HELPER;linux/payload/PlocSupvUartMan.h
|
||||
@ -543,7 +543,8 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
|
||||
0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NvmParameterBase.h
|
||||
0x64a0;FSHLP_SdNotMounted;SD card specified with path string not mounted;160;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h
|
||||
0x64a1;FSHLP_FileNotExists;Specified file does not exist on filesystem;161;FILE_SYSTEM_HELPER;bsp_q7s/fs/FilesystemHelper.h
|
||||
0x65a0;PLMPHLP_FileClosedAccidentally;File accidentally close;160;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocHelper.h
|
||||
0x65a0;PLMPHLP_FileWriteError;File error occured for file transfers from OBC to the MPSoC.;160;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
0x65a1;PLMPHLP_FileReadError;File error occured for file transfers from MPSoC to OBC.;161;PLOC_MPSOC_HELPER;linux/payload/PlocMpsocSpecialComHelper.h
|
||||
0x66a0;SADPL_CommandNotSupported;No description;160;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h
|
||||
0x66a1;SADPL_DeploymentAlreadyExecuting;No description;161;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h
|
||||
0x66a2;SADPL_MainSwitchTimeoutFailure;No description;162;SA_DEPL_HANDLER;mission/SolarArrayDeploymentHandler.h
|
||||
|
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @brief Auto-generated event translation file. Contains 291 translations.
|
||||
* @brief Auto-generated event translation file. Contains 295 translations.
|
||||
* @details
|
||||
* Generated on: 2023-04-17 11:34:19
|
||||
* Generated on: 2023-05-17 17:15:34
|
||||
*/
|
||||
#include "translateEvents.h"
|
||||
|
||||
@ -197,6 +197,10 @@ const char *MPSOC_EXE_INVALID_APID_STRING = "MPSOC_EXE_INVALID_APID";
|
||||
const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH";
|
||||
const char *MPSOC_TM_SIZE_ERROR_STRING = "MPSOC_TM_SIZE_ERROR";
|
||||
const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH";
|
||||
const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR";
|
||||
const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED";
|
||||
const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL";
|
||||
const char *MPSOC_READ_TIMEOUT_STRING = "MPSOC_READ_TIMEOUT";
|
||||
const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF";
|
||||
const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS";
|
||||
const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS";
|
||||
@ -683,6 +687,14 @@ const char *translateEvents(Event event) {
|
||||
return MPSOC_TM_SIZE_ERROR_STRING;
|
||||
case (12613):
|
||||
return MPSOC_TM_CRC_MISSMATCH_STRING;
|
||||
case (12614):
|
||||
return MPSOC_FLASH_READ_PACKET_ERROR_STRING;
|
||||
case (12615):
|
||||
return MPSOC_FLASH_READ_FAILED_STRING;
|
||||
case (12616):
|
||||
return MPSOC_FLASH_READ_SUCCESSFUL_STRING;
|
||||
case (12617):
|
||||
return MPSOC_READ_TIMEOUT_STRING;
|
||||
case (12700):
|
||||
return TRANSITION_BACK_TO_OFF_STRING;
|
||||
case (12701):
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @brief Auto-generated object translation file.
|
||||
* @details
|
||||
* Contains 175 translations.
|
||||
* Generated on: 2023-04-17 11:34:19
|
||||
* Generated on: 2023-05-17 17:15:34
|
||||
*/
|
||||
#include "translateObjects.h"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @brief Auto-generated event translation file. Contains 291 translations.
|
||||
* @brief Auto-generated event translation file. Contains 295 translations.
|
||||
* @details
|
||||
* Generated on: 2023-04-17 11:34:19
|
||||
* Generated on: 2023-05-17 17:15:34
|
||||
*/
|
||||
#include "translateEvents.h"
|
||||
|
||||
@ -197,6 +197,10 @@ const char *MPSOC_EXE_INVALID_APID_STRING = "MPSOC_EXE_INVALID_APID";
|
||||
const char *MPSOC_HELPER_SEQ_CNT_MISMATCH_STRING = "MPSOC_HELPER_SEQ_CNT_MISMATCH";
|
||||
const char *MPSOC_TM_SIZE_ERROR_STRING = "MPSOC_TM_SIZE_ERROR";
|
||||
const char *MPSOC_TM_CRC_MISSMATCH_STRING = "MPSOC_TM_CRC_MISSMATCH";
|
||||
const char *MPSOC_FLASH_READ_PACKET_ERROR_STRING = "MPSOC_FLASH_READ_PACKET_ERROR";
|
||||
const char *MPSOC_FLASH_READ_FAILED_STRING = "MPSOC_FLASH_READ_FAILED";
|
||||
const char *MPSOC_FLASH_READ_SUCCESSFUL_STRING = "MPSOC_FLASH_READ_SUCCESSFUL";
|
||||
const char *MPSOC_READ_TIMEOUT_STRING = "MPSOC_READ_TIMEOUT";
|
||||
const char *TRANSITION_BACK_TO_OFF_STRING = "TRANSITION_BACK_TO_OFF";
|
||||
const char *NEG_V_OUT_OF_BOUNDS_STRING = "NEG_V_OUT_OF_BOUNDS";
|
||||
const char *U_DRO_OUT_OF_BOUNDS_STRING = "U_DRO_OUT_OF_BOUNDS";
|
||||
@ -683,6 +687,14 @@ const char *translateEvents(Event event) {
|
||||
return MPSOC_TM_SIZE_ERROR_STRING;
|
||||
case (12613):
|
||||
return MPSOC_TM_CRC_MISSMATCH_STRING;
|
||||
case (12614):
|
||||
return MPSOC_FLASH_READ_PACKET_ERROR_STRING;
|
||||
case (12615):
|
||||
return MPSOC_FLASH_READ_FAILED_STRING;
|
||||
case (12616):
|
||||
return MPSOC_FLASH_READ_SUCCESSFUL_STRING;
|
||||
case (12617):
|
||||
return MPSOC_READ_TIMEOUT_STRING;
|
||||
case (12700):
|
||||
return TRANSITION_BACK_TO_OFF_STRING;
|
||||
case (12701):
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @brief Auto-generated object translation file.
|
||||
* @details
|
||||
* Contains 175 translations.
|
||||
* Generated on: 2023-04-17 11:34:19
|
||||
* Generated on: 2023-05-17 17:15:34
|
||||
*/
|
||||
#include "translateObjects.h"
|
||||
|
||||
|
@ -2,7 +2,8 @@ target_sources(
|
||||
${OBSW_NAME}
|
||||
PUBLIC PlocMemoryDumper.cpp
|
||||
PlocMpsocHandler.cpp
|
||||
PlocMpsocHelper.cpp
|
||||
PlocMpsocSpecialComHelper.cpp
|
||||
plocMpsocHelpers.cpp
|
||||
PlocSupervisorHandler.cpp
|
||||
PlocSupvUartMan.cpp
|
||||
ScexDleParser.cpp
|
||||
|
@ -8,12 +8,12 @@
|
||||
#include "fsfw/datapool/PoolReadGuard.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
|
||||
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
|
||||
PlocMpsocHandler::PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid,
|
||||
CookieIF* comCookie, PlocMpsocSpecialComHelper* plocMPSoCHelper,
|
||||
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
|
||||
: DeviceHandlerBase(objectId, uartComIFid, comCookie),
|
||||
hkReport(this),
|
||||
plocMPSoCHelper(plocMPSoCHelper),
|
||||
specialComHelper(plocMPSoCHelper),
|
||||
uartIsolatorSwitch(uartIsolatorSwitch),
|
||||
supervisorHandler(supervisorHandler),
|
||||
commandActionHelper(this) {
|
||||
@ -27,9 +27,9 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid
|
||||
spParams.buf = commandBuffer;
|
||||
}
|
||||
|
||||
PlocMPSoCHandler::~PlocMPSoCHandler() {}
|
||||
PlocMpsocHandler::~PlocMpsocHandler() {}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::initialize() {
|
||||
ReturnValue_t PlocMpsocHandler::initialize() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = DeviceHandlerBase::initialize();
|
||||
if (result != returnvalue::OK) {
|
||||
@ -53,24 +53,35 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = manager->subscribeToEventRange(
|
||||
eventQueue->getId(), event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_FAILED),
|
||||
event::getEventId(PlocMPSoCHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
|
||||
result = manager->subscribeToEvent(
|
||||
eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_FAILED));
|
||||
if (result != returnvalue::OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
result = manager->subscribeToEvent(
|
||||
eventQueue->getId(),
|
||||
event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_WRITE_SUCCESSFUL));
|
||||
if (result != returnvalue::OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
result = manager->subscribeToEvent(
|
||||
eventQueue->getId(),
|
||||
event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_READ_SUCCESSFUL));
|
||||
if (result != returnvalue::OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
result = manager->subscribeToEvent(
|
||||
eventQueue->getId(), event::getEventId(PlocMpsocSpecialComHelper::MPSOC_FLASH_READ_FAILED));
|
||||
if (result != returnvalue::OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "PlocMPSoCHandler::initialize: Failed to subscribe to events from "
|
||||
" ploc mpsoc helper"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
result = plocMPSoCHelper->setComIF(communicationInterface);
|
||||
result = specialComHelper->setComIF(communicationInterface);
|
||||
if (result != returnvalue::OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
plocMPSoCHelper->setComCookie(comCookie);
|
||||
plocMPSoCHelper->setSequenceCount(&sequenceCount);
|
||||
specialComHelper->setComCookie(comCookie);
|
||||
specialComHelper->setSequenceCount(&sequenceCount);
|
||||
result = commandActionHelper.initialize();
|
||||
if (result != returnvalue::OK) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
@ -78,7 +89,12 @@ ReturnValue_t PlocMPSoCHandler::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::performOperationHook() {
|
||||
void PlocMpsocHandler::performOperationHook() {
|
||||
if (commandIsPending and cmdCountdown.hasTimedOut()) {
|
||||
commandIsPending = false;
|
||||
// TODO: Better returnvalue?
|
||||
cmdDoneHandler(false, returnvalue::FAILED);
|
||||
}
|
||||
EventMessage event;
|
||||
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK;
|
||||
result = eventQueue->receiveMessage(&event)) {
|
||||
@ -102,10 +118,9 @@ void PlocMPSoCHandler::performOperationHook() {
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
ReturnValue_t PlocMpsocHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
commandIsPending = true;
|
||||
switch (actionId) {
|
||||
case mpsoc::SET_UART_TX_TRISTATE: {
|
||||
uartIsolatorSwitch.pullLow();
|
||||
@ -121,26 +136,38 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
}
|
||||
}
|
||||
|
||||
if (plocMPSoCHelperExecuting) {
|
||||
if (specialComHelperExecuting) {
|
||||
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
|
||||
}
|
||||
|
||||
switch (actionId) {
|
||||
case mpsoc::TC_FLASHWRITE: {
|
||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsoc::FlashWritePusCmd flashWritePusCmd;
|
||||
case mpsoc::TC_FLASH_WRITE_FULL_FILE: {
|
||||
mpsoc::FlashBasePusCmd flashWritePusCmd;
|
||||
result = flashWritePusCmd.extractFields(data, size);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
|
||||
flashWritePusCmd.getMPSoCFile());
|
||||
result = specialComHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
|
||||
flashWritePusCmd.getMPSoCFile());
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
plocMPSoCHelperExecuting = true;
|
||||
specialComHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case mpsoc::TC_FLASH_READ_FULL_FILE: {
|
||||
mpsoc::FlashReadPusCmd flashReadPusCmd;
|
||||
result = flashReadPusCmd.extractFields(data, size);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = specialComHelper->startFlashRead(flashReadPusCmd.getObcFile(),
|
||||
flashReadPusCmd.getMPSoCFile(),
|
||||
flashReadPusCmd.getReadSize());
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
specialComHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (mpsoc::OBSW_RESET_SEQ_COUNT): {
|
||||
@ -150,10 +177,13 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// For longer commands, do not set these.
|
||||
commandIsPending = true;
|
||||
cmdCountdown.resetTimer();
|
||||
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doStartUp() {
|
||||
void PlocMpsocHandler::doStartUp() {
|
||||
if (startupState == StartupState::IDLE) {
|
||||
startupState = StartupState::HW_INIT;
|
||||
}
|
||||
@ -197,48 +227,50 @@ void PlocMPSoCHandler::doStartUp() {
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::doShutDown() {
|
||||
void PlocMpsocHandler::doShutDown() {
|
||||
#ifdef XIPHOS_Q7S
|
||||
#if not OBSW_MPSOC_JTAG_BOOT == 1
|
||||
switch (powerState) {
|
||||
case PowerState::ON:
|
||||
uartIsolatorSwitch.pullLow();
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
||||
powerState = PowerState::SHUTDOWN;
|
||||
break;
|
||||
case PowerState::OFF:
|
||||
sequenceCount = 0;
|
||||
hkReport.setReportingEnabled(false);
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (powerState == PowerState::ON) {
|
||||
uartIsolatorSwitch.pullLow();
|
||||
commandActionHelper.commandAction(supervisorHandler, supv::SHUTDOWN_MPSOC);
|
||||
powerState = PowerState::SHUTDOWN;
|
||||
return;
|
||||
} else if (powerState == PowerState::SHUTDOWN) {
|
||||
// Wait till power state is OFF.
|
||||
return;
|
||||
}
|
||||
#else
|
||||
sequenceCount = 0;
|
||||
uartIsolatorSwitch.pullLow();
|
||||
hkReport.setReportingEnabled(false);
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
powerState = PowerState::OFF;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (specialComHelper != nullptr) {
|
||||
specialComHelper->stopProcess();
|
||||
}
|
||||
hkReport.setReportingEnabled(false);
|
||||
setMode(_MODE_POWER_DOWN);
|
||||
commandIsPending = false;
|
||||
sequenceCount = 0;
|
||||
specialComHelperExecuting = false;
|
||||
startupState = StartupState::IDLE;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
if (not commandIsPending) {
|
||||
ReturnValue_t PlocMpsocHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
if (not commandIsPending and not specialComHelperExecuting) {
|
||||
*id = mpsoc::TC_GET_HK_REPORT;
|
||||
commandIsPending = true;
|
||||
cmdCountdown.resetTimer();
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
ReturnValue_t PlocMpsocHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
return NOTHING_TO_SEND;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
ReturnValue_t PlocMpsocHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
spParams.buf = commandBuffer;
|
||||
@ -329,10 +361,12 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::fillCommandAndReplyMap() {
|
||||
void PlocMpsocHandler::fillCommandAndReplyMap() {
|
||||
this->insertInCommandMap(mpsoc::TC_MEM_WRITE);
|
||||
this->insertInCommandMap(mpsoc::TC_MEM_READ);
|
||||
this->insertInCommandMap(mpsoc::TC_FLASHDELETE);
|
||||
insertInCommandMap(mpsoc::TC_FLASH_WRITE_FULL_FILE);
|
||||
insertInCommandMap(mpsoc::TC_FLASH_READ_FULL_FILE);
|
||||
this->insertInCommandMap(mpsoc::TC_REPLAY_START);
|
||||
this->insertInCommandMap(mpsoc::TC_REPLAY_STOP);
|
||||
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_ON);
|
||||
@ -357,7 +391,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() {
|
||||
this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE);
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
ReturnValue_t PlocMpsocHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
@ -424,10 +458,11 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
|
||||
}
|
||||
// This sequence count ping pong does not make any sense but it is how the MPSoC expects it.
|
||||
sequenceCount++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||
ReturnValue_t PlocMpsocHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
switch (id) {
|
||||
@ -472,14 +507,14 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {
|
||||
void PlocMpsocHandler::setNormalDatapoolEntriesInvalid() {
|
||||
PoolReadGuard pg(&hkReport);
|
||||
hkReport.setValidity(false, true);
|
||||
}
|
||||
|
||||
uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
|
||||
uint32_t PlocMpsocHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; }
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
ReturnValue_t PlocMpsocHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus);
|
||||
localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode);
|
||||
@ -520,11 +555,11 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
|
||||
void PlocMpsocHandler::handleEvent(EventMessage* eventMessage) {
|
||||
object_id_t objectId = eventMessage->getReporter();
|
||||
switch (objectId) {
|
||||
case objects::PLOC_MPSOC_HELPER: {
|
||||
plocMPSoCHelperExecuting = false;
|
||||
specialComHelperExecuting = false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -533,219 +568,194 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcMemWrite(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcMemWrite tcMemWrite(spParams, sequenceCount);
|
||||
result = tcMemWrite.buildPacket(commandData, commandDataLen);
|
||||
result = tcMemWrite.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcMemWrite.getFullPacketLen());
|
||||
finishTcPrep(tcMemWrite);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcMemRead(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcMemRead tcMemRead(spParams, sequenceCount);
|
||||
result = tcMemRead.buildPacket(commandData, commandDataLen);
|
||||
result = tcMemRead.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcMemRead.getFullPacketLen());
|
||||
finishTcPrep(tcMemRead);
|
||||
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcFlashDelete(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return MPSoCReturnValuesIF::NAME_TOO_LONG;
|
||||
}
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcFlashDelete tcFlashDelete(spParams, sequenceCount);
|
||||
result = tcFlashDelete.buildPacket(
|
||||
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
|
||||
std::string filename = std::string(reinterpret_cast<const char*>(commandData), commandDataLen);
|
||||
result = tcFlashDelete.setPayload(filename);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcFlashDelete.getFullPacketLen());
|
||||
finishTcPrep(tcFlashDelete);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcReplayStart(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcReplayStart tcReplayStart(spParams, sequenceCount);
|
||||
result = tcReplayStart.buildPacket(commandData, commandDataLen);
|
||||
result = tcReplayStart.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcReplayStart.getFullPacketLen());
|
||||
finishTcPrep(tcReplayStart);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcReplayStop() {
|
||||
mpsoc::TcReplayStop tcReplayStop(spParams, sequenceCount);
|
||||
result = tcReplayStop.buildPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcReplayStop.getFullPacketLen());
|
||||
finishTcPrep(tcReplayStop);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(spParams, sequenceCount);
|
||||
result = tcDownlinkPwrOn.buildPacket(commandData, commandDataLen);
|
||||
result = tcDownlinkPwrOn.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcDownlinkPwrOn.getFullPacketLen());
|
||||
finishTcPrep(tcDownlinkPwrOn);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkPwrOff() {
|
||||
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(spParams, sequenceCount);
|
||||
result = tcDownlinkPwrOff.buildPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcDownlinkPwrOff.getFullPacketLen());
|
||||
finishTcPrep(tcDownlinkPwrOff);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() {
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcGetHkReport() {
|
||||
mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount);
|
||||
ReturnValue_t result = tcGetHkReport.buildPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcGetHkReport.getFullPacketLen());
|
||||
finishTcPrep(tcGetHkReport);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(spParams, sequenceCount);
|
||||
result = tcReplayWriteSeq.buildPacket(commandData, commandDataLen);
|
||||
ReturnValue_t result = tcReplayWriteSeq.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcReplayWriteSeq.getFullPacketLen());
|
||||
finishTcPrep(tcReplayWriteSeq);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcModeReplay() {
|
||||
mpsoc::TcModeReplay tcModeReplay(spParams, sequenceCount);
|
||||
result = tcModeReplay.buildPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcModeReplay.getFullPacketLen());
|
||||
finishTcPrep(tcModeReplay);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcModeIdle() {
|
||||
mpsoc::TcModeIdle tcModeIdle(spParams, sequenceCount);
|
||||
result = tcModeIdle.buildPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcModeIdle.getFullPacketLen());
|
||||
finishTcPrep(tcModeIdle);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcCamCmdSend(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
mpsoc::TcCamcmdSend tcCamCmdSend(spParams, sequenceCount);
|
||||
result = tcCamCmdSend.buildPacket(commandData, commandDataLen);
|
||||
ReturnValue_t result = tcCamCmdSend.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcCamCmdSend.getFullPacketLen());
|
||||
finishTcPrep(tcCamCmdSend);
|
||||
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcCamTakePic(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount);
|
||||
ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen);
|
||||
ReturnValue_t result = tcCamTakePic.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcCamTakePic.getFullPacketLen());
|
||||
finishTcPrep(tcCamTakePic);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcSimplexSendFile(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount);
|
||||
ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen);
|
||||
ReturnValue_t result = tcSimplexSendFile.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcSimplexSendFile.getFullPacketLen());
|
||||
finishTcPrep(tcSimplexSendFile);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcGetDirContent(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount);
|
||||
ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen);
|
||||
ReturnValue_t result = tcGetDirContent.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcGetDirContent.getFullPacketLen());
|
||||
finishTcPrep(tcGetDirContent);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount);
|
||||
ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen);
|
||||
ReturnValue_t result = tcDownlinkDataModulate.setPayload(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcDownlinkDataModulate.getFullPacketLen());
|
||||
finishTcPrep(tcDownlinkDataModulate);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() {
|
||||
ReturnValue_t PlocMpsocHandler::prepareTcModeSnapshot() {
|
||||
mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount);
|
||||
ReturnValue_t result = tcModeSnapshot.buildPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
finishTcPrep(tcModeSnapshot.getFullPacketLen());
|
||||
finishTcPrep(tcModeSnapshot);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::finishTcPrep(size_t packetLen) {
|
||||
ReturnValue_t PlocMpsocHandler::finishTcPrep(mpsoc::TcBase& tcBase) {
|
||||
nextReplyId = mpsoc::ACK_REPORT;
|
||||
ReturnValue_t result = tcBase.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
rawPacket = commandBuffer;
|
||||
rawPacketLen = packetLen;
|
||||
rawPacketLen = tcBase.getFullPacketLen();
|
||||
sequenceCount++;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
||||
ReturnValue_t PlocMpsocHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
|
||||
if (CRC::crc16ccitt(start, foundLen) != 0) {
|
||||
return MPSoCReturnValuesIF::CRC_FAILURE;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
||||
ReturnValue_t PlocMpsocHandler::handleAckReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
|
||||
@ -763,10 +773,9 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
||||
|
||||
switch (apid) {
|
||||
case mpsoc::apid::ACK_FAILURE: {
|
||||
sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl;
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
uint16_t status = getStatus(data);
|
||||
printStatus(data);
|
||||
uint16_t status = mpsoc::getStatusFromRawData(data);
|
||||
sif::warning << "MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
triggerEvent(ACK_FAILURE, commandId, status);
|
||||
}
|
||||
@ -790,7 +799,7 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
||||
ReturnValue_t PlocMpsocHandler::handleExecutionReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
|
||||
@ -802,40 +811,22 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
||||
|
||||
uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK;
|
||||
|
||||
auto cmdDoneHandler = [&](bool success) {
|
||||
if (normalCmdPending) {
|
||||
normalCmdPending = false;
|
||||
}
|
||||
commandIsPending = false;
|
||||
auto commandIter = deviceCommandMap.find(getPendingCommand());
|
||||
if (commandIter != deviceCommandMap.end()) {
|
||||
commandIter->second.isExecuting = false;
|
||||
if (commandIter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) {
|
||||
actionHelper.finish(success, commandIter->second.sendReplyTo, getPendingCommand(), result);
|
||||
}
|
||||
}
|
||||
disableAllReplies();
|
||||
};
|
||||
switch (apid) {
|
||||
case (mpsoc::apid::EXE_SUCCESS): {
|
||||
cmdDoneHandler(true);
|
||||
cmdDoneHandler(true, result);
|
||||
break;
|
||||
}
|
||||
case (mpsoc::apid::EXE_FAILURE): {
|
||||
// TODO: Interpretation of status field in execution report
|
||||
sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report"
|
||||
<< std::endl;
|
||||
DeviceCommandId_t commandId = getPendingCommand();
|
||||
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
uint16_t status = getStatus(data);
|
||||
triggerEvent(EXE_FAILURE, commandId, status);
|
||||
} else {
|
||||
if (commandId == DeviceHandlerIF::NO_COMMAND_ID) {
|
||||
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
|
||||
}
|
||||
printStatus(data);
|
||||
uint16_t status = mpsoc::getStatusFromRawData(data);
|
||||
sif::warning << "MPSoC EXE Failure: " << mpsoc::getStatusString(status) << std::endl;
|
||||
triggerEvent(EXE_FAILURE, commandId, status);
|
||||
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||
result = IGNORE_REPLY_DATA;
|
||||
cmdDoneHandler(false);
|
||||
cmdDoneHandler(false, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -848,7 +839,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
||||
ReturnValue_t PlocMpsocHandler::handleMemoryReadReport(const uint8_t* data) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = verifyPacket(data, tmMemReadReport.rememberRequestedSize);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
@ -864,7 +855,7 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) {
|
||||
ReturnValue_t PlocMpsocHandler::handleGetHkReport(const uint8_t* data) {
|
||||
ReturnValue_t result = verifyPacket(data, foundPacketLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -1042,7 +1033,7 @@ ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
|
||||
ReturnValue_t PlocMpsocHandler::handleCamCmdRpt(const uint8_t* data) {
|
||||
ReturnValue_t result = verifyPacket(data, foundPacketLen);
|
||||
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
|
||||
sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl;
|
||||
@ -1062,7 +1053,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
ReturnValue_t PlocMpsocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command,
|
||||
uint8_t expectedReplies, bool useAlternateId,
|
||||
DeviceCommandId_t alternateReplyID) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
@ -1178,7 +1169,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::setNextReplyId() {
|
||||
void PlocMpsocHandler::setNextReplyId() {
|
||||
switch (getPendingCommand()) {
|
||||
case mpsoc::TC_MEM_READ:
|
||||
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
|
||||
@ -1198,7 +1189,7 @@ void PlocMPSoCHandler::setNextReplyId() {
|
||||
}
|
||||
}
|
||||
|
||||
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
size_t PlocMpsocHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
size_t replyLen = 0;
|
||||
|
||||
if (nextReplyId == mpsoc::NONE) {
|
||||
@ -1239,19 +1230,19 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
|
||||
return replyLen;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHandler::doSendReadHook() {
|
||||
ReturnValue_t PlocMpsocHandler::doSendReadHook() {
|
||||
// Prevent DHB from polling UART during commands executed by the mpsoc helper task
|
||||
if (plocMPSoCHelperExecuting) {
|
||||
if (specialComHelperExecuting) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
MessageQueueIF* PlocMPSoCHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
||||
MessageQueueIF* PlocMpsocHandler::getCommandQueuePtr() { return commandActionHelperQueue; }
|
||||
|
||||
void PlocMPSoCHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
|
||||
void PlocMpsocHandler::stepSuccessfulReceived(ActionId_t actionId, uint8_t step) { return; }
|
||||
|
||||
void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
void PlocMpsocHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
switch (actionId) {
|
||||
case supv::START_MPSOC: {
|
||||
@ -1274,11 +1265,11 @@ void PlocMPSoCHandler::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
void PlocMpsocHandler::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
return;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
void PlocMpsocHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
if (actionId != supv::EXE_REPORT) {
|
||||
sif::debug << "PlocMPSoCHandler::completionSuccessfulReceived: Did not expect this action "
|
||||
<< "ID" << std::endl;
|
||||
@ -1299,11 +1290,11 @@ void PlocMPSoCHandler::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
void PlocMpsocHandler::completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) {
|
||||
handleActionCommandFailure(actionId);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize,
|
||||
void PlocMpsocHandler::handleDeviceTm(const uint8_t* data, size_t dataSize,
|
||||
DeviceCommandId_t replyId) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
@ -1329,7 +1320,7 @@ void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize,
|
||||
}
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::disableAllReplies() {
|
||||
void PlocMpsocHandler::disableAllReplies() {
|
||||
using namespace mpsoc;
|
||||
DeviceReplyMap::iterator iter;
|
||||
|
||||
@ -1392,7 +1383,7 @@ void PlocMPSoCHandler::disableAllReplies() {
|
||||
nextReplyId = mpsoc::NONE;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
|
||||
void PlocMpsocHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(replyId);
|
||||
if (iter == deviceReplyMap.end()) {
|
||||
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
|
||||
@ -1409,7 +1400,7 @@ void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_
|
||||
info->isExecuting = false;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::disableExeReportReply() {
|
||||
void PlocMpsocHandler::disableExeReportReply() {
|
||||
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
|
||||
DeviceReplyInfo* info = &(iter->second);
|
||||
info->delayCycles = 0;
|
||||
@ -1418,16 +1409,7 @@ void PlocMPSoCHandler::disableExeReportReply() {
|
||||
info->command->second.expectedReplies = 0;
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::printStatus(const uint8_t* data) {
|
||||
uint16_t status = (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
|
||||
sif::info << "Verification report status: " << getStatusString(status) << std::endl;
|
||||
}
|
||||
|
||||
uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) {
|
||||
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
|
||||
}
|
||||
|
||||
void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
void PlocMpsocHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
switch (actionId) {
|
||||
case supv::ACK_REPORT:
|
||||
case supv::EXE_REPORT:
|
||||
@ -1460,96 +1442,27 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) {
|
||||
LocalPoolDataSetBase* PlocMpsocHandler::getDataSetHandle(sid_t sid) {
|
||||
if (sid == hkReport.getSid()) {
|
||||
return &hkReport;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string PlocMPSoCHandler::getStatusString(uint16_t status) {
|
||||
switch (status) {
|
||||
case (mpsoc::status_code::UNKNOWN_APID): {
|
||||
return "Unknown APID";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INCORRECT_LENGTH): {
|
||||
return "Incorrect length";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INCORRECT_CRC): {
|
||||
return "Incorrect crc";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): {
|
||||
return "Incorrect packet sequence count";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): {
|
||||
return "TC not allowed in this mode";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::TC_EXEUTION_DISABLED): {
|
||||
return "TC execution disabled";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_MOUNT_FAILED): {
|
||||
return "Flash mount failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): {
|
||||
return "Flash file already closed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): {
|
||||
return "Flash file open failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): {
|
||||
return "Flash file not open";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): {
|
||||
return "Flash unmount failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): {
|
||||
return "Heap allocation failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INVALID_PARAMETER): {
|
||||
return "Invalid parameter";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::NOT_INITIALIZED): {
|
||||
return "Not initialized";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::REBOOT_IMMINENT): {
|
||||
return "Reboot imminent";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::CORRUPT_DATA): {
|
||||
return "Corrupt data";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): {
|
||||
return "Flash correctable mismatch";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): {
|
||||
return "Flash uncorrectable mismatch";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::DEFAULT_ERROR_CODE): {
|
||||
return "Default error code";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
std::stringstream ss;
|
||||
ss << "0x" << std::hex << status;
|
||||
return ss.str();
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
bool PlocMpsocHandler::dontCheckQueue() {
|
||||
// The TC and TMs need to be handled strictly sequentially, so while a command is pending,
|
||||
// more specifically while replies are still expected, do not check the queue.s
|
||||
return commandIsPending;
|
||||
}
|
||||
|
||||
void PlocMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) {
|
||||
commandIsPending = false;
|
||||
auto commandIter = deviceCommandMap.find(getPendingCommand());
|
||||
if (commandIter != deviceCommandMap.end()) {
|
||||
commandIter->second.isExecuting = false;
|
||||
if (commandIter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) {
|
||||
actionHelper.finish(success, commandIter->second.sendReplyTo, getPendingCommand(), result);
|
||||
}
|
||||
}
|
||||
disableAllReplies();
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifndef BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
|
||||
#define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
|
||||
|
||||
#include <linux/payload/PlocMpsocHelper.h>
|
||||
#include <linux/payload/PlocMpsocSpecialComHelper.h>
|
||||
#include <linux/payload/mpsocRetvals.h>
|
||||
#include <linux/payload/plocMpscoDefs.h>
|
||||
#include <linux/payload/plocMpsocHelpers.h>
|
||||
#include <linux/payload/plocSupvDefs.h>
|
||||
|
||||
#include <string>
|
||||
@ -28,9 +28,10 @@
|
||||
* @note The sequence count in the space packets must be incremented with each received and sent
|
||||
* packet otherwise the MPSoC will reply with an acknowledgment failure report.
|
||||
*
|
||||
* @author J. Meier
|
||||
* NOTE: This is not an example for a good device handler, DO NOT USE THIS AS A REFERENCE HANDLER.
|
||||
* @author J. Meier, R. Mueller
|
||||
*/
|
||||
class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -43,10 +44,10 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
* module in the programmable logic
|
||||
* @param supervisorHandler Object ID of the supervisor handler
|
||||
*/
|
||||
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
|
||||
PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch,
|
||||
PlocMpsocHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
|
||||
PlocMpsocSpecialComHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch,
|
||||
object_id_t supervisorHandler);
|
||||
virtual ~PlocMPSoCHandler();
|
||||
virtual ~PlocMpsocHandler();
|
||||
virtual ReturnValue_t initialize() override;
|
||||
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) override;
|
||||
@ -79,6 +80,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
|
||||
ReturnValue_t doSendReadHook() override;
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
bool dontCheckQueue() override;
|
||||
|
||||
private:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
|
||||
@ -104,11 +106,9 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
|
||||
static const uint16_t APID_MASK = 0x7FF;
|
||||
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
|
||||
static const uint8_t STATUS_OFFSET = 10;
|
||||
|
||||
mpsoc::HkReport hkReport;
|
||||
|
||||
bool normalCmdPending = false;
|
||||
MessageQueueIF* eventQueue = nullptr;
|
||||
MessageQueueIF* commandActionHelperQueue = nullptr;
|
||||
|
||||
@ -162,13 +162,13 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
|
||||
SerialComIF* uartComIf = nullptr;
|
||||
|
||||
PlocMPSoCHelper* plocMPSoCHelper = nullptr;
|
||||
PlocMpsocSpecialComHelper* specialComHelper = nullptr;
|
||||
Gpio uartIsolatorSwitch;
|
||||
object_id_t supervisorHandler = 0;
|
||||
CommandActionHelper commandActionHelper;
|
||||
|
||||
// Used to block incoming commands when MPSoC helper class is currently executing a command
|
||||
bool plocMPSoCHelperExecuting = false;
|
||||
bool specialComHelperExecuting = false;
|
||||
bool commandIsPending = false;
|
||||
|
||||
struct TmMemReadReport {
|
||||
@ -177,6 +177,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
};
|
||||
|
||||
TmMemReadReport tmMemReadReport;
|
||||
Countdown cmdCountdown = Countdown(10000);
|
||||
|
||||
struct TelemetryBuffer {
|
||||
uint16_t length = 0;
|
||||
@ -213,7 +214,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
ReturnValue_t prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen);
|
||||
ReturnValue_t prepareTcModeSnapshot();
|
||||
void finishTcPrep(size_t packetLen);
|
||||
ReturnValue_t finishTcPrep(mpsoc::TcBase& tcBase);
|
||||
|
||||
/**
|
||||
* @brief This function checks the crc of the received PLOC reply.
|
||||
@ -295,15 +296,11 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
|
||||
*/
|
||||
void disableExeReportReply();
|
||||
|
||||
void printStatus(const uint8_t* data);
|
||||
|
||||
ReturnValue_t prepareTcModeReplay();
|
||||
|
||||
uint16_t getStatus(const uint8_t* data);
|
||||
void cmdDoneHandler(bool success, ReturnValue_t result);
|
||||
|
||||
void handleActionCommandFailure(ActionId_t actionId);
|
||||
|
||||
std::string getStatusString(uint16_t status);
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */
|
||||
|
@ -1,355 +0,0 @@
|
||||
#include <linux/payload/PlocMpsocHelper.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "bsp_q7s/fs/FilesystemHelper.h"
|
||||
#endif
|
||||
|
||||
#include "mission/utility/Timestamp.h"
|
||||
|
||||
using namespace ploc;
|
||||
|
||||
PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) {
|
||||
spParams.buf = commandBuffer;
|
||||
spParams.maxSize = sizeof(commandBuffer);
|
||||
}
|
||||
|
||||
PlocMPSoCHelper::~PlocMPSoCHelper() {}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::initialize() {
|
||||
#ifdef XIPHOS_Q7S
|
||||
sdcMan = SdCardManager::instance();
|
||||
if (sdcMan == nullptr) {
|
||||
sif::warning << "PlocMPSoCHelper::initialize: Invalid SD Card Manager" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::performOperation(uint8_t operationCode) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
semaphore.acquire();
|
||||
while (true) {
|
||||
#if OBSW_THREAD_TRACING == 1
|
||||
trace::threadTrace(opCounter, "PLOC MPSOC Helper");
|
||||
#endif
|
||||
switch (internalState) {
|
||||
case InternalState::IDLE: {
|
||||
semaphore.acquire();
|
||||
break;
|
||||
}
|
||||
case InternalState::FLASH_WRITE: {
|
||||
result = performFlashWrite();
|
||||
if (result == returnvalue::OK) {
|
||||
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL);
|
||||
} else {
|
||||
triggerEvent(MPSOC_FLASH_WRITE_FAILED);
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHelper::performOperation: Invalid state" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::setComIF(DeviceCommunicationIF* communicationInterface_) {
|
||||
uartComIF = dynamic_cast<SerialComIF*>(communicationInterface_);
|
||||
if (uartComIF == nullptr) {
|
||||
sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
|
||||
|
||||
void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
||||
sequenceCount = sequenceCount_;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
#ifdef XIPHOS_Q7S
|
||||
result = FilesystemHelper::checkPath(obcFile);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = FilesystemHelper::fileExists(mpsocFile);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
#ifdef TE0720_1CFA
|
||||
if (not std::filesystem::exists(obcFile)) {
|
||||
sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist"
|
||||
<< std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
#endif
|
||||
|
||||
flashWrite.obcFile = obcFile;
|
||||
flashWrite.mpsocFile = mpsocFile;
|
||||
internalState = InternalState::FLASH_WRITE;
|
||||
result = resetHelper();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::resetHelper() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
semaphore.release();
|
||||
spParams.buf = commandBuffer;
|
||||
terminate = false;
|
||||
result = uartComIF->flushUartRxBuffer(comCookie);
|
||||
return result;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::stopProcess() { terminate = true; }
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = flashfopen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t tempData[mpsoc::MAX_DATA_SIZE];
|
||||
std::ifstream file(flashWrite.obcFile, std::ifstream::binary);
|
||||
// Set position of next character to end of file input stream
|
||||
file.seekg(0, file.end);
|
||||
// tellg returns position of character in input stream
|
||||
size_t remainingSize = file.tellg();
|
||||
size_t dataLength = 0;
|
||||
size_t bytesRead = 0;
|
||||
while (remainingSize > 0) {
|
||||
if (terminate) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
if (remainingSize > mpsoc::MAX_DATA_SIZE) {
|
||||
dataLength = mpsoc::MAX_DATA_SIZE;
|
||||
} else {
|
||||
dataLength = remainingSize;
|
||||
}
|
||||
if (file.is_open()) {
|
||||
file.seekg(bytesRead, file.beg);
|
||||
file.read(reinterpret_cast<char*>(tempData), dataLength);
|
||||
bytesRead += dataLength;
|
||||
remainingSize -= dataLength;
|
||||
} else {
|
||||
return FILE_CLOSED_ACCIDENTALLY;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
|
||||
result = tc.buildPacket(tempData, dataLength);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(tc);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result = flashfclose();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::flashfopen() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
spParams.buf = commandBuffer;
|
||||
(*sequenceCount)++;
|
||||
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
||||
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(flashFopen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::flashfclose() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
spParams.buf = commandBuffer;
|
||||
(*sequenceCount)++;
|
||||
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
||||
result = flashFclose.createPacket(flashWrite.mpsocFile);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handlePacketTransmission(flashFclose);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(ploc::SpTcBase& tc) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = sendCommand(tc);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleAck();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleExe();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
|
||||
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));
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handleAck() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = handleTmReception(mpsoc::SIZE_ACK_REPORT);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
|
||||
result = checkReceivedTm(tmPacket);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = tmPacket.getApid();
|
||||
if (apid != mpsoc::apid::ACK_SUCCESS) {
|
||||
handleAckApidFailure(apid);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
|
||||
if (apid == mpsoc::apid::ACK_FAILURE) {
|
||||
triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Received acknowledgement failure "
|
||||
<< "report" << std::endl;
|
||||
} else {
|
||||
triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report "
|
||||
<< "but received space packet with apid " << std::hex << apid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handleExe() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
result = handleTmReception(mpsoc::SIZE_EXE_REPORT);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
ploc::SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
|
||||
result = checkReceivedTm(tmPacket);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = tmPacket.getApid();
|
||||
if (apid != mpsoc::apid::EXE_SUCCESS) {
|
||||
handleExeApidFailure(apid);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) {
|
||||
if (apid == mpsoc::apid::EXE_FAILURE) {
|
||||
triggerEvent(MPSOC_EXE_FAILURE_REPORT, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Received execution failure "
|
||||
<< "report" << std::endl;
|
||||
} else {
|
||||
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleExeApidFailure: Expected execution report "
|
||||
<< "but received space packet with apid " << std::hex << apid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
size_t readBytes = 0;
|
||||
size_t currentBytes = 0;
|
||||
for (int retries = 0; retries < RETRIES; retries++) {
|
||||
result = receive(tmBuf.data() + readBytes, ¤tBytes, remainingBytes);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
readBytes += currentBytes;
|
||||
remainingBytes = remainingBytes - currentBytes;
|
||||
if (remainingBytes == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (remainingBytes != 0) {
|
||||
sif::warning << "PlocMPSoCHelper::handleTmReception: Failed to receive reply" << std::endl;
|
||||
triggerEvent(MPSOC_MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState));
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) {
|
||||
ReturnValue_t result = reader.checkSize();
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed"
|
||||
<< std::endl;
|
||||
triggerEvent(MPSOC_TM_SIZE_ERROR);
|
||||
return result;
|
||||
}
|
||||
reader.checkCrc();
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl;
|
||||
triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount);
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
uint16_t recvSeqCnt = reader.getSequenceCount();
|
||||
if (recvSeqCnt != *sequenceCount) {
|
||||
triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
|
||||
*sequenceCount = recvSeqCnt;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
uint8_t* buffer = nullptr;
|
||||
result = uartComIF->requestReceiveMessage(comCookie, requestBytes);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "PlocMPSoCHelper::receive: Failed to request reply" << std::endl;
|
||||
triggerEvent(MPSOC_HELPER_REQUESTING_REPLY_FAILED, result,
|
||||
static_cast<uint32_t>(static_cast<uint32_t>(internalState)));
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
result = uartComIF->readReceivedMessage(comCookie, &buffer, readBytes);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "PlocMPSoCHelper::receive: Failed to read received message" << std::endl;
|
||||
triggerEvent(MPSOC_HELPER_READING_REPLY_FAILED, result, static_cast<uint32_t>(internalState));
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
if (*readBytes > 0) {
|
||||
std::memcpy(data, buffer, *readBytes);
|
||||
}
|
||||
return result;
|
||||
}
|
544
linux/payload/PlocMpsocSpecialComHelper.cpp
Normal file
544
linux/payload/PlocMpsocSpecialComHelper.cpp
Normal file
@ -0,0 +1,544 @@
|
||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <linux/payload/PlocMpsocSpecialComHelper.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef XIPHOS_Q7S
|
||||
#include "bsp_q7s/fs/FilesystemHelper.h"
|
||||
#endif
|
||||
|
||||
#include "mission/utility/Timestamp.h"
|
||||
|
||||
using namespace ploc;
|
||||
|
||||
PlocMpsocSpecialComHelper::PlocMpsocSpecialComHelper(object_id_t objectId)
|
||||
: SystemObject(objectId) {
|
||||
spParams.buf = commandBuffer;
|
||||
spParams.maxSize = sizeof(commandBuffer);
|
||||
}
|
||||
|
||||
PlocMpsocSpecialComHelper::~PlocMpsocSpecialComHelper() {}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::initialize() {
|
||||
#ifdef XIPHOS_Q7S
|
||||
sdcMan = SdCardManager::instance();
|
||||
if (sdcMan == nullptr) {
|
||||
sif::warning << "PlocMPSoCHelper::initialize: Invalid SD Card Manager" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::performOperation(uint8_t operationCode) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
semaphore.acquire();
|
||||
while (true) {
|
||||
#if OBSW_THREAD_TRACING == 1
|
||||
trace::threadTrace(opCounter, "PLOC MPSOC Helper");
|
||||
#endif
|
||||
switch (internalState) {
|
||||
case InternalState::IDLE: {
|
||||
semaphore.acquire();
|
||||
break;
|
||||
}
|
||||
case InternalState::FLASH_WRITE: {
|
||||
result = performFlashWrite();
|
||||
if (result == returnvalue::OK) {
|
||||
triggerEvent(MPSOC_FLASH_WRITE_SUCCESSFUL, sequenceCount->get());
|
||||
} else {
|
||||
triggerEvent(MPSOC_FLASH_WRITE_FAILED, sequenceCount->get());
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
case InternalState::FLASH_READ: {
|
||||
result = performFlashRead();
|
||||
if (result == returnvalue::OK) {
|
||||
triggerEvent(MPSOC_FLASH_READ_SUCCESSFUL, sequenceCount->get());
|
||||
} else {
|
||||
triggerEvent(MPSOC_FLASH_READ_FAILED, sequenceCount->get());
|
||||
}
|
||||
internalState = InternalState::IDLE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
sif::debug << "PlocMPSoCHelper::performOperation: Invalid state" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::setComIF(DeviceCommunicationIF* communicationInterface_) {
|
||||
uartComIF = dynamic_cast<SerialComIF*>(communicationInterface_);
|
||||
if (uartComIF == nullptr) {
|
||||
sif::warning << "PlocMPSoCHelper::initialize: Invalid uart com if" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void PlocMpsocSpecialComHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_; }
|
||||
|
||||
void PlocMpsocSpecialComHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
||||
sequenceCount = sequenceCount_;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::startFlashWrite(std::string obcFile,
|
||||
std::string mpsocFile) {
|
||||
if (internalState != InternalState::IDLE) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile));
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
internalState = InternalState::FLASH_WRITE;
|
||||
return semaphore.release();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::startFlashRead(std::string obcFile, std::string mpsocFile,
|
||||
size_t readFileSize) {
|
||||
if (internalState != InternalState::IDLE) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile));
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
flashReadAndWrite.totalReadSize = readFileSize;
|
||||
internalState = InternalState::FLASH_READ;
|
||||
return semaphore.release();
|
||||
}
|
||||
|
||||
void PlocMpsocSpecialComHelper::resetHelper() {
|
||||
spParams.buf = commandBuffer;
|
||||
terminate = false;
|
||||
uartComIF->flushUartRxBuffer(comCookie);
|
||||
}
|
||||
|
||||
void PlocMpsocSpecialComHelper::stopProcess() { terminate = true; }
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
std::ifstream file(flashReadAndWrite.obcFile, std::ifstream::binary);
|
||||
if (file.bad()) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
result = flashfopen(mpsoc::FileAccessModes::WRITE | mpsoc::FileAccessModes::OPEN_ALWAYS);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
// Set position of next character to end of file input stream
|
||||
file.seekg(0, file.end);
|
||||
// tellg returns position of character in input stream
|
||||
size_t remainingSize = file.tellg();
|
||||
size_t dataLength = 0;
|
||||
size_t bytesRead = 0;
|
||||
while (remainingSize > 0) {
|
||||
if (terminate) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
// The minus 4 is necessary for unknown reasons. Maybe some bug in the ILH software?
|
||||
if (remainingSize > mpsoc::MAX_FLASH_WRITE_DATA_SIZE - 4) {
|
||||
dataLength = mpsoc::MAX_FLASH_WRITE_DATA_SIZE - 4;
|
||||
} else {
|
||||
dataLength = remainingSize;
|
||||
}
|
||||
if (file.bad() or not file.is_open()) {
|
||||
return FILE_WRITE_ERROR;
|
||||
}
|
||||
file.seekg(bytesRead, file.beg);
|
||||
file.read(reinterpret_cast<char*>(fileBuf.data()), dataLength);
|
||||
bytesRead += dataLength;
|
||||
remainingSize -= dataLength;
|
||||
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
|
||||
result = tc.setPayload(fileBuf.data(), dataLength);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = tc.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
result = handlePacketTransmissionNoReply(tc);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result = flashfclose();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() {
|
||||
std::error_code e;
|
||||
std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::trunc | std::ios::binary);
|
||||
if (ofile.bad()) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
ReturnValue_t result = flashfopen(mpsoc::FileAccessModes::READ);
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
return result;
|
||||
}
|
||||
size_t readSoFar = 0;
|
||||
size_t nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE;
|
||||
while (readSoFar < flashReadAndWrite.totalReadSize) {
|
||||
if (terminate) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
nextReadSize = mpsoc::MAX_FLASH_READ_DATA_SIZE;
|
||||
if (flashReadAndWrite.totalReadSize - readSoFar < mpsoc::MAX_FLASH_READ_DATA_SIZE) {
|
||||
nextReadSize = flashReadAndWrite.totalReadSize - readSoFar;
|
||||
}
|
||||
if (ofile.bad() or not ofile.is_open()) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
return FILE_READ_ERROR;
|
||||
}
|
||||
mpsoc::TcFlashRead flashReadRequest(spParams, *sequenceCount);
|
||||
result = flashReadRequest.setPayload(nextReadSize);
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
return result;
|
||||
}
|
||||
result = flashReadRequest.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
result = handlePacketTransmissionFlashRead(flashReadRequest, ofile, nextReadSize);
|
||||
if (result != returnvalue::OK) {
|
||||
std::filesystem::remove(flashReadAndWrite.obcFile, e);
|
||||
return result;
|
||||
}
|
||||
readSoFar += nextReadSize;
|
||||
}
|
||||
result = flashfclose();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::flashfopen(uint8_t mode) {
|
||||
spParams.buf = commandBuffer;
|
||||
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
|
||||
ReturnValue_t result = flashFopen.setPayload(flashReadAndWrite.mpsocFile, mode);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = flashFopen.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
result = handlePacketTransmissionNoReply(flashFopen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::flashfclose() {
|
||||
spParams.buf = commandBuffer;
|
||||
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
|
||||
ReturnValue_t result = flashFclose.finishPacket();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
(*sequenceCount)++;
|
||||
result = handlePacketTransmissionNoReply(flashFclose);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc,
|
||||
std::ofstream& ofile,
|
||||
size_t expectedReadLen) {
|
||||
ReturnValue_t result = sendCommand(tc);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleAck();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleTmReception();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// We have the nominal case where the flash read report appears first, or the case where we
|
||||
// get an EXE failure immediately.
|
||||
if (spReader.getApid() == mpsoc::apid::TM_FLASH_READ_REPORT) {
|
||||
result = handleFlashReadReply(ofile, expectedReadLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return handleExe();
|
||||
} else if (spReader.getApid() == mpsoc::apid::EXE_FAILURE) {
|
||||
handleExeFailure();
|
||||
} else {
|
||||
triggerEvent(MPSOC_EXE_INVALID_APID, spReader.getApid(), static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PLOC MPSoC: Expected execution report "
|
||||
<< "but received space packet with apid " << std::hex << spReader.getApid()
|
||||
<< std::endl;
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::handlePacketTransmissionNoReply(ploc::SpTcBase& tc) {
|
||||
ReturnValue_t result = sendCommand(tc);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = handleAck();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return handleExe();
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::sendCommand(ploc::SpTcBase& tc) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
|
||||
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));
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::handleAck() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = handleTmReception();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = checkReceivedTm();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = spReader.getApid();
|
||||
if (apid != mpsoc::apid::ACK_SUCCESS) {
|
||||
handleAckApidFailure(spReader);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
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());
|
||||
sif::warning << "PLOC MPSoC ACK Failure: " << mpsoc::getStatusString(status) << std::endl;
|
||||
triggerEvent(MPSOC_ACK_FAILURE_REPORT, static_cast<uint32_t>(internalState), status);
|
||||
} else {
|
||||
triggerEvent(MPSOC_ACK_INVALID_APID, apid, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PlocMPSoCHelper::handleAckApidFailure: Expected acknowledgement report "
|
||||
<< "but received space packet with apid " << std::hex << apid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::handleExe() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
|
||||
result = handleTmReception();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = checkReceivedTm();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = spReader.getApid();
|
||||
if (apid == mpsoc::apid::EXE_FAILURE) {
|
||||
handleExeFailure();
|
||||
return returnvalue::FAILED;
|
||||
} else if (apid != mpsoc::apid::EXE_SUCCESS) {
|
||||
triggerEvent(MPSOC_EXE_INVALID_APID, apid, static_cast<uint32_t>(internalState));
|
||||
sif::warning << "PLOC MPSoC: Expected execution report "
|
||||
<< "but received space packet with apid " << std::hex << apid << std::endl;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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 = receive(tmBuf.data() + readBytes, 6, ¤tBytes);
|
||||
if (result != returnvalue::OK) {
|
||||
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, ¤tBytes);
|
||||
readBytes += currentBytes;
|
||||
if (fullPacketLen == readBytes) {
|
||||
break;
|
||||
}
|
||||
usleep(usleepDelay);
|
||||
if (usleepDelay < 200000) {
|
||||
usleepDelay *= 4;
|
||||
}
|
||||
}
|
||||
// arrayprinter::print(tmBuf.data(), readBytes);
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::handleFlashReadReply(std::ofstream& ofile,
|
||||
size_t expectedReadLen) {
|
||||
ReturnValue_t result = checkReceivedTm();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
uint16_t apid = spReader.getApid();
|
||||
if (apid != mpsoc::apid::TM_FLASH_READ_REPORT) {
|
||||
triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_APID_ERROR);
|
||||
sif::warning << "PLOC MPSoC Flash Read: Unexpected APID" << std::endl;
|
||||
return result;
|
||||
}
|
||||
const uint8_t* packetData = spReader.getPacketData();
|
||||
size_t deserDummy = spReader.getPacketDataLen() - mpsoc::CRC_SIZE;
|
||||
uint32_t receivedReadLen = 0;
|
||||
// I think this is buggy, weird stuff in the short name field.
|
||||
// std::string receivedShortName = std::string(reinterpret_cast<const char*>(packetData), 12);
|
||||
// if (receivedShortName != flashReadAndWrite.mpsocFile.substr(0, 11)) {
|
||||
// sif::warning << "PLOC MPSoC Flash Read: Missmatch between request file name and "
|
||||
// "received file name"
|
||||
// << std::endl;
|
||||
// triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_FILENAME_ERROR);
|
||||
// return returnvalue::FAILED;
|
||||
// }
|
||||
packetData += 12;
|
||||
result = SerializeAdapter::deSerialize(&receivedReadLen, &packetData, &deserDummy,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (receivedReadLen != expectedReadLen) {
|
||||
sif::warning << "PLOC MPSoC Flash Read: Missmatch between request read length and "
|
||||
"received read length"
|
||||
<< std::endl;
|
||||
triggerEvent(MPSOC_FLASH_READ_PACKET_ERROR, FlashReadErrorType::FLASH_READ_READLEN_ERROR);
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
ofile.write(reinterpret_cast<const char*>(packetData), receivedReadLen);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::fileCheck(std::string obcFile) {
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t result = FilesystemHelper::checkPath(obcFile);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
#elif defined(TE0720_1CFA)
|
||||
if (not std::filesystem::exists(obcFile)) {
|
||||
sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist"
|
||||
<< std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
#endif
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::startFlashReadOrWriteBase(std::string obcFile,
|
||||
std::string mpsocFile) {
|
||||
ReturnValue_t result = fileCheck(obcFile);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
flashReadAndWrite.obcFile = std::move(obcFile);
|
||||
flashReadAndWrite.mpsocFile = std::move(mpsocFile);
|
||||
resetHelper();
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMpsocSpecialComHelper::checkReceivedTm() {
|
||||
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;
|
||||
}
|
||||
spReader.checkCrc();
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "PLOC MPSoC: CRC check failed" << std::endl;
|
||||
triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount);
|
||||
return result;
|
||||
}
|
||||
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::receive(uint8_t* data, size_t requestBytes,
|
||||
size_t* readBytes) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
uint8_t* buffer = nullptr;
|
||||
result = uartComIF->requestReceiveMessage(comCookie, requestBytes);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "PlocMPSoCHelper::receive: Failed to request reply" << std::endl;
|
||||
triggerEvent(MPSOC_HELPER_REQUESTING_REPLY_FAILED, result,
|
||||
static_cast<uint32_t>(static_cast<uint32_t>(internalState)));
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
result = uartComIF->readReceivedMessage(comCookie, &buffer, readBytes);
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "PlocMPSoCHelper::receive: Failed to read received message" << std::endl;
|
||||
triggerEvent(MPSOC_HELPER_READING_REPLY_FAILED, result, static_cast<uint32_t>(internalState));
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
if (*readBytes > 0) {
|
||||
std::memcpy(data, buffer, *readBytes);
|
||||
}
|
||||
return result;
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
#ifndef BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_
|
||||
#define BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_
|
||||
|
||||
#include <linux/payload/plocMpscoDefs.h>
|
||||
#include <linux/payload/plocMpsocHelpers.h>
|
||||
#include <mission/utility/trace.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "fsfw/devicehandlers/CookieIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/osal/linux/BinarySemaphore.h"
|
||||
@ -22,14 +23,14 @@
|
||||
* MPSoC and OBC.
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
||||
class PlocMpsocSpecialComHelper : public SystemObject, public ExecutableObjectIF {
|
||||
public:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HELPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] Flash write fails
|
||||
static const Event MPSOC_FLASH_WRITE_FAILED = MAKE_EVENT(0, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Flash write successful
|
||||
static const Event MPSOC_FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(1, severity::LOW);
|
||||
static const Event MPSOC_FLASH_WRITE_SUCCESSFUL = MAKE_EVENT(1, severity::INFO);
|
||||
//! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command
|
||||
//! to the MPSoC
|
||||
//! P1: Return value returned by the communication interface sendMessage function
|
||||
@ -71,9 +72,19 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
||||
static const Event MPSOC_HELPER_SEQ_CNT_MISMATCH = MAKE_EVENT(11, severity::LOW);
|
||||
static const Event MPSOC_TM_SIZE_ERROR = MAKE_EVENT(12, severity::LOW);
|
||||
static const Event MPSOC_TM_CRC_MISSMATCH = MAKE_EVENT(13, severity::LOW);
|
||||
static const Event MPSOC_FLASH_READ_PACKET_ERROR = MAKE_EVENT(14, severity::LOW);
|
||||
static const Event MPSOC_FLASH_READ_FAILED = MAKE_EVENT(15, severity::LOW);
|
||||
static const Event MPSOC_FLASH_READ_SUCCESSFUL = MAKE_EVENT(16, severity::INFO);
|
||||
static const Event MPSOC_READ_TIMEOUT = MAKE_EVENT(17, severity::LOW);
|
||||
|
||||
PlocMPSoCHelper(object_id_t objectId);
|
||||
virtual ~PlocMPSoCHelper();
|
||||
enum FlashReadErrorType : uint32_t {
|
||||
FLASH_READ_APID_ERROR = 0,
|
||||
FLASH_READ_FILENAME_ERROR = 1,
|
||||
FLASH_READ_READLEN_ERROR = 2
|
||||
};
|
||||
|
||||
PlocMpsocSpecialComHelper(object_id_t objectId);
|
||||
virtual ~PlocMpsocSpecialComHelper();
|
||||
|
||||
ReturnValue_t initialize() override;
|
||||
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||
@ -90,6 +101,14 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
||||
* @return returnvalue::OK if successful, otherwise error return value
|
||||
*/
|
||||
ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile);
|
||||
/**
|
||||
*
|
||||
* @param obcFile Full target file name on OBC
|
||||
* @param mpsocFile The file on the MPSoC which should be copied ot the OBC
|
||||
* @param readFileSize The size of the file on the MPSoC.
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t startFlashRead(std::string obcFile, std::string mpsocFile, size_t readFileSize);
|
||||
|
||||
/**
|
||||
* @brief Can be used to interrupt a running data transfer.
|
||||
@ -104,20 +123,25 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
||||
private:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HELPER;
|
||||
|
||||
//! [EXPORT] : [COMMENT] File accidentally close
|
||||
static const ReturnValue_t FILE_CLOSED_ACCIDENTALLY = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] File error occured for file transfers from OBC to the MPSoC.
|
||||
static const ReturnValue_t FILE_WRITE_ERROR = MAKE_RETURN_CODE(0xA0);
|
||||
//! [EXPORT] : [COMMENT] File error occured for file transfers from MPSoC to OBC.
|
||||
static const ReturnValue_t FILE_READ_ERROR = MAKE_RETURN_CODE(0xA1);
|
||||
|
||||
// Maximum number of times the communication interface retries polling data from the reply
|
||||
// buffer
|
||||
static const int RETRIES = 10000;
|
||||
|
||||
struct FlashWrite {
|
||||
struct FlashInfo {
|
||||
std::string obcFile;
|
||||
std::string mpsocFile;
|
||||
};
|
||||
|
||||
struct FlashWrite flashWrite;
|
||||
struct FlashRead : public FlashInfo {
|
||||
size_t totalReadSize = 0;
|
||||
};
|
||||
|
||||
struct FlashRead flashReadAndWrite;
|
||||
#if OBSW_THREAD_TRACING == 1
|
||||
uint32_t opCounter = 0;
|
||||
#endif
|
||||
@ -134,7 +158,10 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
||||
SpacePacketCreator creator;
|
||||
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
|
||||
|
||||
std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf;
|
||||
Countdown tmCountdown = Countdown(5000);
|
||||
|
||||
std::array<uint8_t, mpsoc::SP_MAX_DATA_SIZE> fileBuf{};
|
||||
std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf{};
|
||||
|
||||
bool terminate = false;
|
||||
|
||||
@ -147,20 +174,27 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF {
|
||||
CookieIF* comCookie = nullptr;
|
||||
// Sequence count, must be set by Ploc MPSoC Handler
|
||||
SourceSequenceCounter* sequenceCount = nullptr;
|
||||
ploc::SpTmReader spReader;
|
||||
|
||||
ReturnValue_t resetHelper();
|
||||
void resetHelper();
|
||||
ReturnValue_t performFlashWrite();
|
||||
ReturnValue_t flashfopen();
|
||||
ReturnValue_t performFlashRead();
|
||||
ReturnValue_t flashfopen(uint8_t accessMode);
|
||||
ReturnValue_t flashfclose();
|
||||
ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc);
|
||||
ReturnValue_t handlePacketTransmissionNoReply(ploc::SpTcBase& tc);
|
||||
ReturnValue_t handlePacketTransmissionFlashRead(mpsoc::TcFlashRead& tc, std::ofstream& ofile,
|
||||
size_t expectedReadLen);
|
||||
ReturnValue_t handleFlashReadReply(std::ofstream& ofile, size_t expectedReadLen);
|
||||
ReturnValue_t sendCommand(ploc::SpTcBase& tc);
|
||||
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes);
|
||||
ReturnValue_t receive(uint8_t* data, size_t requestBytes, size_t* readBytes);
|
||||
ReturnValue_t handleAck();
|
||||
ReturnValue_t handleExe();
|
||||
void handleAckApidFailure(uint16_t apid);
|
||||
void handleExeApidFailure(uint16_t apid);
|
||||
ReturnValue_t handleTmReception(size_t remainingBytes);
|
||||
ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader);
|
||||
ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile);
|
||||
ReturnValue_t fileCheck(std::string obcFile);
|
||||
void handleAckApidFailure(const ploc::SpTmReader& reader);
|
||||
void handleExeFailure();
|
||||
ReturnValue_t handleTmReception();
|
||||
ReturnValue_t checkReceivedTm();
|
||||
};
|
||||
|
||||
#endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */
|
95
linux/payload/plocMpsocHelpers.cpp
Normal file
95
linux/payload/plocMpsocHelpers.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include "plocMpsocHelpers.h"
|
||||
|
||||
uint16_t mpsoc::getStatusFromRawData(const uint8_t* data) {
|
||||
return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1);
|
||||
}
|
||||
std::string mpsoc::getStatusString(uint16_t status) {
|
||||
switch (status) {
|
||||
case (mpsoc::status_code::UNKNOWN_APID): {
|
||||
return "Unknown APID";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INCORRECT_LENGTH): {
|
||||
return "Incorrect length";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INCORRECT_CRC): {
|
||||
return "Incorrect crc";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INCORRECT_PKT_SEQ_CNT): {
|
||||
return "Incorrect packet sequence count";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::TC_NOT_ALLOWED_IN_MODE): {
|
||||
return "TC not allowed in this mode";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::TC_EXEUTION_DISABLED): {
|
||||
return "TC execution disabled";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_MOUNT_FAILED): {
|
||||
return "Flash mount failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_ALREADY_OPEN): {
|
||||
return "Flash file already open";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_ALREADY_CLOSED): {
|
||||
return "Flash file already closed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_OPEN_FAILED): {
|
||||
return "Flash file open failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_FILE_NOT_OPEN): {
|
||||
return "Flash file not open";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_UNMOUNT_FAILED): {
|
||||
return "Flash unmount failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::HEAP_ALLOCATION_FAILED): {
|
||||
return "Heap allocation failed";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::INVALID_PARAMETER): {
|
||||
return "Invalid parameter";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::NOT_INITIALIZED): {
|
||||
return "Not initialized";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::REBOOT_IMMINENT): {
|
||||
return "Reboot imminent";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::CORRUPT_DATA): {
|
||||
return "Corrupt data";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_CORRECTABLE_MISMATCH): {
|
||||
return "Flash correctable mismatch";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::FLASH_UNCORRECTABLE_MISMATCH): {
|
||||
return "Flash uncorrectable mismatch";
|
||||
break;
|
||||
}
|
||||
case (mpsoc::status_code::DEFAULT_ERROR_CODE): {
|
||||
return "Default error code";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
std::stringstream ss;
|
||||
ss << "0x" << std::hex << status;
|
||||
return ss.str().c_str();
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
@ -13,6 +13,20 @@
|
||||
|
||||
namespace mpsoc {
|
||||
|
||||
enum FileAccessModes : uint8_t {
|
||||
// Opens a file, fails if the file does not exist.
|
||||
OPEN_EXISTING = 0x00,
|
||||
READ = 0x01,
|
||||
WRITE = 0x02,
|
||||
// Creates a new file, fails if it already exists.
|
||||
CREATE_NEW = 0x04,
|
||||
// Creates a new file, existing file is truncated and overwritten.
|
||||
CREATE_ALWAYS = 0x08,
|
||||
// Opens the file if it is existing. If not, a new file is created.
|
||||
OPEN_ALWAYS = 0x10,
|
||||
OPEN_APPEND = 0x30
|
||||
};
|
||||
|
||||
static constexpr uint32_t HK_SET_ID = 0;
|
||||
|
||||
namespace poolid {
|
||||
@ -62,7 +76,7 @@ static const DeviceCommandId_t EXE_REPORT = 5;
|
||||
static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 6;
|
||||
static const DeviceCommandId_t TC_FLASHFOPEN = 7;
|
||||
static const DeviceCommandId_t TC_FLASHFCLOSE = 8;
|
||||
static const DeviceCommandId_t TC_FLASHWRITE = 9;
|
||||
static const DeviceCommandId_t TC_FLASH_WRITE_FULL_FILE = 9;
|
||||
static const DeviceCommandId_t TC_FLASHDELETE = 10;
|
||||
static const DeviceCommandId_t TC_REPLAY_START = 11;
|
||||
static const DeviceCommandId_t TC_REPLAY_STOP = 12;
|
||||
@ -83,6 +97,7 @@ static const DeviceCommandId_t TC_GET_HK_REPORT = 26;
|
||||
static const DeviceCommandId_t TM_GET_HK_REPORT = 27;
|
||||
static const DeviceCommandId_t TC_FLASH_GET_DIRECTORY_CONTENT = 28;
|
||||
static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29;
|
||||
static constexpr DeviceCommandId_t TC_FLASH_READ_FULL_FILE = 30;
|
||||
|
||||
// Will reset the sequence count of the OBSW
|
||||
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50;
|
||||
@ -104,7 +119,8 @@ static const uint16_t TC_DOWNLINK_PWR_ON = 0x113;
|
||||
static const uint16_t TC_MEM_WRITE = 0x114;
|
||||
static const uint16_t TC_MEM_READ = 0x115;
|
||||
static const uint16_t TC_CAM_TAKE_PIC = 0x116;
|
||||
static const uint16_t TC_FLASHWRITE = 0x117;
|
||||
static constexpr uint16_t TC_FLASHWRITE = 0x117;
|
||||
static constexpr uint16_t TC_FLASHREAD = 0x118;
|
||||
static const uint16_t TC_FLASHFOPEN = 0x119;
|
||||
static const uint16_t TC_FLASHFCLOSE = 0x11A;
|
||||
static constexpr uint16_t TC_FLASH_GET_DIRECTORY_CONTENT = 0x11B;
|
||||
@ -125,6 +141,7 @@ static const uint16_t ACK_FAILURE = 0x401;
|
||||
static const uint16_t EXE_SUCCESS = 0x402;
|
||||
static const uint16_t EXE_FAILURE = 0x403;
|
||||
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
|
||||
static const uint16_t TM_FLASH_READ_REPORT = 0x405;
|
||||
static constexpr uint16_t TM_FLASH_DIRECTORY_CONTENT = 0x406;
|
||||
static const uint16_t TM_CAM_CMD_RPT = 0x407;
|
||||
static constexpr uint16_t TM_HK_GET_REPORT = 0x408;
|
||||
@ -137,6 +154,8 @@ static const char NULL_TERMINATOR = '\0';
|
||||
static const uint8_t MIN_SPACE_PACKET_LENGTH = 7;
|
||||
static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
|
||||
|
||||
static const uint8_t STATUS_OFFSET = 10;
|
||||
|
||||
static constexpr size_t CRC_SIZE = 2;
|
||||
|
||||
/**
|
||||
@ -160,9 +179,15 @@ static const uint16_t LENGTH_TC_MEM_READ = 8;
|
||||
* at sheet README
|
||||
*/
|
||||
static constexpr size_t SP_MAX_SIZE = 1024;
|
||||
static const size_t MAX_REPLY_SIZE = SP_MAX_SIZE * 3;
|
||||
static const size_t MAX_COMMAND_SIZE = SP_MAX_SIZE;
|
||||
static const size_t MAX_DATA_SIZE = 1016;
|
||||
static constexpr size_t MAX_REPLY_SIZE = SP_MAX_SIZE * 3;
|
||||
static constexpr size_t MAX_COMMAND_SIZE = SP_MAX_SIZE;
|
||||
// 1016 bytes.
|
||||
static constexpr size_t SP_MAX_DATA_SIZE = SP_MAX_SIZE - ccsds::HEADER_LEN - CRC_SIZE;
|
||||
static constexpr size_t FLASH_READ_MIN_OVERHEAD = 16;
|
||||
// 1000 bytes.
|
||||
static const size_t MAX_FLASH_READ_DATA_SIZE = SP_MAX_DATA_SIZE - FLASH_READ_MIN_OVERHEAD;
|
||||
// 1012 bytes, 4 bytes for the write length.
|
||||
static constexpr size_t MAX_FLASH_WRITE_DATA_SIZE = SP_MAX_DATA_SIZE - sizeof(uint32_t);
|
||||
|
||||
/**
|
||||
* The replay write sequence command has a maximum delay for the execution report which amounts to
|
||||
@ -185,7 +210,7 @@ static const uint16_t TC_EXEUTION_DISABLED = 0x5E2;
|
||||
static const uint16_t FLASH_MOUNT_FAILED = 0x5E3;
|
||||
static const uint16_t FLASH_FILE_ALREADY_CLOSED = 0x5E4;
|
||||
static const uint16_t FLASH_FILE_OPEN_FAILED = 0x5E5;
|
||||
static const uint16_t FLASH_FILE_ALREDY_OPEN = 0x5E6;
|
||||
static const uint16_t FLASH_FILE_ALREADY_OPEN = 0x5E6;
|
||||
static const uint16_t FLASH_FILE_NOT_OPEN = 0x5E7;
|
||||
static const uint16_t FLASH_UNMOUNT_FAILED = 0x5E8;
|
||||
static const uint16_t HEAP_ALLOCATION_FAILED = 0x5E9;
|
||||
@ -210,7 +235,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
|
||||
virtual ~TcBase() = default;
|
||||
|
||||
// Initial length field of space packet. Will always be updated when packet is created.
|
||||
static const uint16_t INIT_LENGTH = 2;
|
||||
static const uint16_t INIT_LENGTH = CRC_SIZE;
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -220,47 +245,23 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
|
||||
*/
|
||||
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
|
||||
: ploc::SpTcBase(params, apid, 0, sequenceCount) {
|
||||
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
||||
spParams.setFullPayloadLen(INIT_LENGTH);
|
||||
}
|
||||
|
||||
ReturnValue_t buildPacket() { return buildPacket(nullptr, 0); }
|
||||
|
||||
/**
|
||||
* @brief Function to initialize the space packet
|
||||
*
|
||||
* @param commandData Pointer to command specific data
|
||||
* @param commandDataLen Length of command data
|
||||
*
|
||||
* @brief Function to finsh and write the space packet. It is expected that the user has
|
||||
* set the payload fields in the child class*
|
||||
* @return returnvalue::OK if packet creation was successful, otherwise error return value
|
||||
*/
|
||||
ReturnValue_t buildPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
payloadStart = spParams.buf + ccsds::HEADER_LEN;
|
||||
ReturnValue_t res;
|
||||
if (commandData != nullptr and commandDataLen > 0) {
|
||||
res = initPacket(commandData, commandDataLen);
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t finishPacket() {
|
||||
updateSpFields();
|
||||
res = checkSizeAndSerializeHeader();
|
||||
ReturnValue_t res = checkSizeAndSerializeHeader();
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Must be overwritten by the child class to define the command specific parameters
|
||||
*
|
||||
* @param commandData Pointer to received command data
|
||||
* @param commandDataLen Length of received command data
|
||||
*/
|
||||
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -278,8 +279,7 @@ class TcMemRead : public TcBase {
|
||||
|
||||
uint16_t getMemLen() const { return memLen; }
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -325,8 +325,7 @@ class TcMemWrite : public TcBase {
|
||||
TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -368,72 +367,58 @@ class TcMemWrite : public TcBase {
|
||||
/**
|
||||
* @brief Class to help creation of flash fopen command.
|
||||
*/
|
||||
class FlashFopen : public ploc::SpTcBase {
|
||||
class FlashFopen : public TcBase {
|
||||
public:
|
||||
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||
: TcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
|
||||
|
||||
static const char APPEND = 'a';
|
||||
static const char WRITE = 'w';
|
||||
static const char READ = 'r';
|
||||
|
||||
ReturnValue_t createPacket(std::string filename, char accessMode_) {
|
||||
accessMode = accessMode_;
|
||||
ReturnValue_t setPayload(std::string filename, uint8_t mode) {
|
||||
accessMode = mode;
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE);
|
||||
spParams.setFullPayloadLen(256 + sizeof(uint8_t) + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(spParams.buf + nameSize) = NULL_TERMINATOR;
|
||||
std::memcpy(payloadStart + nameSize + sizeof(NULL_TERMINATOR), &accessMode, sizeof(accessMode));
|
||||
updateSpFields();
|
||||
return calcAndSetCrc();
|
||||
// payloadStart[nameSize] = NULL_TERMINATOR;
|
||||
std::memset(payloadStart + nameSize, 0, 256 - nameSize);
|
||||
// payloadStart[255] = NULL_TERMINATOR;
|
||||
payloadStart[256] = accessMode;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
private:
|
||||
char accessMode = APPEND;
|
||||
uint8_t accessMode = FileAccessModes::OPEN_EXISTING;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to help creation of flash fclose command.
|
||||
*/
|
||||
class FlashFclose : public ploc::SpTcBase {
|
||||
class FlashFclose : public TcBase {
|
||||
public:
|
||||
FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: ploc::SpTcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t createPacket(std::string filename) {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
*(payloadStart + nameSize) = NULL_TERMINATOR;
|
||||
return calcAndSetCrc();
|
||||
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {
|
||||
spParams.setFullPayloadLen(CRC_SIZE);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to build flash write space packet.
|
||||
*/
|
||||
class TcFlashWrite : public ploc::SpTcBase {
|
||||
class TcFlashWrite : public TcBase {
|
||||
public:
|
||||
TcFlashWrite(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: ploc::SpTcBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
|
||||
: TcBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t buildPacket(const uint8_t* writeData, uint32_t writeLen_) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
ReturnValue_t setPayload(const uint8_t* writeData, uint32_t writeLen_) {
|
||||
writeLen = writeLen_;
|
||||
if (writeLen > MAX_DATA_SIZE) {
|
||||
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
|
||||
if (writeLen > MAX_FLASH_WRITE_DATA_SIZE) {
|
||||
sif::error << "TcFlashWrite: Command data too big" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
spParams.setFullPayloadLen(static_cast<uint16_t>(writeLen) + 4 + CRC_SIZE);
|
||||
result = checkPayloadLen();
|
||||
spParams.setFullPayloadLen(sizeof(uint32_t) + static_cast<uint16_t>(writeLen) + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
@ -443,11 +428,11 @@ class TcFlashWrite : public ploc::SpTcBase {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart + sizeof(writeLen), writeData, writeLen);
|
||||
std::memcpy(payloadStart + sizeof(uint32_t), writeData, writeLen);
|
||||
updateSpFields();
|
||||
auto res = checkSizeAndSerializeHeader();
|
||||
if (res != returnvalue::OK) {
|
||||
return res;
|
||||
result = checkSizeAndSerializeHeader();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return calcAndSetCrc();
|
||||
}
|
||||
@ -456,15 +441,52 @@ class TcFlashWrite : public ploc::SpTcBase {
|
||||
uint32_t writeLen = 0;
|
||||
};
|
||||
|
||||
class TcFlashRead : public TcBase {
|
||||
public:
|
||||
TcFlashRead(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_FLASHREAD, sequenceCount) {}
|
||||
|
||||
ReturnValue_t setPayload(uint32_t readLen) {
|
||||
if (readLen > MAX_FLASH_READ_DATA_SIZE) {
|
||||
sif::error << "TcFlashRead: Read length " << readLen << " too large" << std::endl;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
spParams.setFullPayloadLen(sizeof(uint32_t) + CRC_SIZE);
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
size_t serializedSize = ccsds::HEADER_LEN;
|
||||
result = SerializeAdapter::serialize(&readLen, payloadStart, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
updateSpFields();
|
||||
result = checkSizeAndSerializeHeader();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = calcAndSetCrc();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
readSize = readLen;
|
||||
return result;
|
||||
}
|
||||
|
||||
uint32_t readSize = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class to help creation of flash delete command.
|
||||
*/
|
||||
class TcFlashDelete : public ploc::SpTcBase {
|
||||
class TcFlashDelete : public TcBase {
|
||||
public:
|
||||
TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: ploc::SpTcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
|
||||
: TcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t buildPacket(std::string filename) {
|
||||
ReturnValue_t setPayload(std::string filename) {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setFullPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
auto res = checkPayloadLen();
|
||||
@ -503,8 +525,7 @@ class TcReplayStart : public TcBase {
|
||||
TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
spParams.setFullPayloadLen(commandDataLen + CRC_SIZE);
|
||||
result = lengthCheck(commandDataLen);
|
||||
@ -552,8 +573,7 @@ class TcDownlinkPwrOn : public TcBase {
|
||||
TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
@ -626,7 +646,7 @@ class TcGetDirContent : public TcBase {
|
||||
TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {}
|
||||
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
// Yeah it needs to be 256.. even if the path is shorter.
|
||||
spParams.setFullPayloadLen(256 + CRC_SIZE);
|
||||
@ -659,8 +679,7 @@ class TcReplayWriteSeq : public TcBase {
|
||||
TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE);
|
||||
result = lengthCheck(commandDataLen);
|
||||
@ -689,36 +708,69 @@ class TcReplayWriteSeq : public TcBase {
|
||||
/**
|
||||
* @brief Helps to extract the fields of the flash write command from the PUS packet.
|
||||
*/
|
||||
class FlashWritePusCmd : public MPSoCReturnValuesIF {
|
||||
class FlashBasePusCmd : public MPSoCReturnValuesIF {
|
||||
public:
|
||||
FlashWritePusCmd(){};
|
||||
FlashBasePusCmd() = default;
|
||||
virtual ~FlashBasePusCmd() = default;
|
||||
|
||||
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||
virtual ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
obcFile = std::string(reinterpret_cast<const char*>(commandData));
|
||||
if (obcFile.size() > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||
size_t fileLen = strnlen(reinterpret_cast<const char*>(commandData), commandDataLen);
|
||||
if (fileLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsocFile = std::string(
|
||||
reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR));
|
||||
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
|
||||
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 > MAX_FILENAME_SIZE) {
|
||||
return MPSOC_FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsocFile = std::string(
|
||||
reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR),
|
||||
fileLen);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
std::string getObcFile() { return obcFile; }
|
||||
const std::string& getObcFile() const { return obcFile; }
|
||||
|
||||
std::string getMPSoCFile() { return mpsocFile; }
|
||||
const std::string& getMPSoCFile() const { return mpsocFile; }
|
||||
|
||||
protected:
|
||||
size_t getParsedSize() const {
|
||||
return getObcFile().size() + getMPSoCFile().size() + 2 * SIZE_NULL_TERMINATOR;
|
||||
}
|
||||
static const size_t SIZE_NULL_TERMINATOR = 1;
|
||||
|
||||
private:
|
||||
static const size_t SIZE_NULL_TERMINATOR = 1;
|
||||
std::string obcFile = "";
|
||||
std::string mpsocFile = "";
|
||||
std::string obcFile;
|
||||
std::string mpsocFile;
|
||||
};
|
||||
|
||||
class FlashReadPusCmd : public FlashBasePusCmd {
|
||||
public:
|
||||
FlashReadPusCmd(){};
|
||||
|
||||
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = FlashBasePusCmd::extractFields(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (commandDataLen < (getParsedSize() + 4)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
size_t deserDummy = 4;
|
||||
return SerializeAdapter::deSerialize(&readSize, commandData + getParsedSize(), &deserDummy,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
size_t getReadSize() const { return readSize; }
|
||||
|
||||
private:
|
||||
size_t readSize = 0;
|
||||
};
|
||||
/**
|
||||
* @brief Class to build replay stop space packet.
|
||||
*/
|
||||
@ -754,7 +806,7 @@ class TcCamTakePic : public TcBase {
|
||||
TcCamTakePic(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_CAM_TAKE_PIC, sequenceCount) {}
|
||||
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
@ -783,7 +835,7 @@ class TcSimplexSendFile : public TcBase {
|
||||
TcSimplexSendFile(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_SIMPLEX_SEND_FILE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
@ -808,7 +860,7 @@ class TcDownlinkDataModulate : public TcBase {
|
||||
TcDownlinkDataModulate(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_DOWNLINK_DATA_MODULATE, sequenceCount) {}
|
||||
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
@ -826,8 +878,7 @@ class TcCamcmdSend : public TcBase {
|
||||
TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount)
|
||||
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t setPayload(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > MAX_DATA_LENGTH) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
@ -912,6 +963,9 @@ class HkReport : public StaticLocalDataSet<36> {
|
||||
lp_var_t<uint8_t>(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this);
|
||||
};
|
||||
|
||||
uint16_t getStatusFromRawData(const uint8_t* data);
|
||||
std::string getStatusString(uint16_t status);
|
||||
|
||||
} // namespace mpsoc
|
||||
|
||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */
|
@ -17,6 +17,7 @@ extern "C" {
|
||||
#include <thread>
|
||||
|
||||
#include "OBSWConfig.h"
|
||||
#include "eive/definitions.h"
|
||||
|
||||
std::atomic_bool JCFG_DONE(false);
|
||||
|
||||
@ -152,7 +153,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (startracker::SET_JSON_FILE_NAME): {
|
||||
if (size > MAX_PATH_SIZE) {
|
||||
if (size > config::MAX_PATH_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
paramJsonFile = std::string(reinterpret_cast<const char*>(data), size);
|
||||
@ -189,7 +190,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (size > MAX_PATH_SIZE + MAX_FILE_NAME) {
|
||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
result = strHelper->startImageUpload(std::string(reinterpret_cast<const char*>(data), size));
|
||||
@ -204,7 +205,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (size > MAX_PATH_SIZE) {
|
||||
if (size > config::MAX_PATH_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
result =
|
||||
@ -228,14 +229,14 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (startracker::CHANGE_IMAGE_DOWNLOAD_FILE): {
|
||||
if (size > MAX_FILE_NAME) {
|
||||
if (size > config::MAX_FILENAME_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
strHelper->setDownloadImageName(std::string(reinterpret_cast<const char*>(data), size));
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case (startracker::SET_FLASH_READ_FILENAME): {
|
||||
if (size > MAX_FILE_NAME) {
|
||||
if (size > config::MAX_FILENAME_SIZE) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
strHelper->setFlashReadFilename(std::string(reinterpret_cast<const char*>(data), size));
|
||||
@ -246,7 +247,7 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (size > MAX_PATH_SIZE + MAX_FILE_NAME) {
|
||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
result =
|
||||
@ -1568,7 +1569,7 @@ ReturnValue_t StarTrackerHandler::executeFlashReadCommand(const uint8_t* command
|
||||
<< std::endl;
|
||||
return result;
|
||||
}
|
||||
if (commandDataLen - sizeof(startRegion) - sizeof(length) > MAX_PATH_SIZE) {
|
||||
if (commandDataLen - sizeof(startRegion) - sizeof(length) > config::MAX_PATH_SIZE) {
|
||||
sif::warning << "StarTrackerHandler::executeFlashReadCommand: Received command with invalid"
|
||||
<< " path and filename" << std::endl;
|
||||
return FILE_PATH_TOO_LONG;
|
||||
@ -1708,7 +1709,7 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData
|
||||
bool reinitSet) {
|
||||
// Stopwatch watch;
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
if (commandDataLen > MAX_PATH_SIZE) {
|
||||
if (commandDataLen > config::MAX_PATH_SIZE) {
|
||||
return FILE_PATH_TOO_LONG;
|
||||
}
|
||||
if (reinitSet) {
|
||||
|
@ -144,9 +144,6 @@ class StarTrackerHandler : public DeviceHandlerBase {
|
||||
//! [EXPORT] : [COMMENT] Failed to boot star tracker into bootloader mode
|
||||
static const Event BOOTING_BOOTLOADER_FAILED_EVENT = MAKE_EVENT(2, severity::LOW);
|
||||
|
||||
static const size_t MAX_PATH_SIZE = 50;
|
||||
static const size_t MAX_FILE_NAME = 30;
|
||||
|
||||
static const uint8_t STATUS_OFFSET = 2;
|
||||
static const uint8_t PARAMS_OFFSET = 2;
|
||||
static const uint8_t TICKS_OFFSET = 3;
|
||||
|
Loading…
Reference in New Issue
Block a user