v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
21 changed files with 591 additions and 255 deletions
Showing only changes of commit 790a71974e - Show all commits

View File

@ -10,9 +10,12 @@ list yields a list of all related PRs for each release.
# [unreleased] # [unreleased]
# [v1.13.0] # [v1.14.0]
# [v1.13.0] 24.08.2022
- Added first version of ACS Controller with gathers MGM data in a set - Added first version of ACS Controller with gathers MGM data in a set
- Some tweaks for IMTQ handler
# [v1.12.1] 05.07.2022 # [v1.12.1] 05.07.2022

View File

@ -9,8 +9,8 @@
# ############################################################################## # ##############################################################################
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
set(OBSW_VERSION_MAJOR_IF_GIT_FAILS 0) set(OBSW_VERSION_MAJOR_IF_GIT_FAILS 1)
set(OBSW_VERSION_MINOR_IF_GIT_FAILS 0) set(OBSW_VERSION_MINOR_IF_GIT_FAILS 13)
set(OBSW_VERSION_REVISION_IF_GIT_FAILS 0) set(OBSW_VERSION_REVISION_IF_GIT_FAILS 0)
# set(CMAKE_VERBOSE TRUE) # set(CMAKE_VERBOSE TRUE)

View File

@ -194,20 +194,23 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
13605;0x3525;SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL;LOW;Requesting event buffer was successful;linux/devices/ploc/PlocSupvHelper.h 13605;0x3525;SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL;LOW;Requesting event buffer was successful;linux/devices/ploc/PlocSupvHelper.h
13606;0x3526;SUPV_EVENT_BUFFER_REQUEST_FAILED;LOW;Requesting event buffer failed;linux/devices/ploc/PlocSupvHelper.h 13606;0x3526;SUPV_EVENT_BUFFER_REQUEST_FAILED;LOW;Requesting event buffer failed;linux/devices/ploc/PlocSupvHelper.h
13607;0x3527;SUPV_EVENT_BUFFER_REQUEST_TERMINATED;LOW;Terminated event buffer request by command P1: Number of packets read before process was terminated;linux/devices/ploc/PlocSupvHelper.h 13607;0x3527;SUPV_EVENT_BUFFER_REQUEST_TERMINATED;LOW;Terminated event buffer request by command P1: Number of packets read before process was terminated;linux/devices/ploc/PlocSupvHelper.h
13608;0x3528;SUPV_SENDING_COMMAND_FAILED;LOW;;linux/devices/ploc/PlocSupvHelper.h 13608;0x3528;SUPV_MEM_CHECK_OK;INFO;;linux/devices/ploc/PlocSupvHelper.h
13609;0x3529;SUPV_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 supervisor helper;linux/devices/ploc/PlocSupvHelper.h 13609;0x3529;SUPV_MEM_CHECK_FAIL;INFO;;linux/devices/ploc/PlocSupvHelper.h
13610;0x352a;SUPV_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 supervisor helper;linux/devices/ploc/PlocSupvHelper.h 13616;0x3530;SUPV_SENDING_COMMAND_FAILED;LOW;;linux/devices/ploc/PlocSupvHelper.h
13611;0x352b;SUPV_MISSING_ACK;LOW;Did not receive acknowledgement report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/devices/ploc/PlocSupvHelper.h 13617;0x3531;SUPV_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 supervisor helper;linux/devices/ploc/PlocSupvHelper.h
13612;0x352c;SUPV_MISSING_EXE;LOW;Supervisor did not receive execution report P1: Number of bytes missing P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h 13618;0x3532;SUPV_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 supervisor helper;linux/devices/ploc/PlocSupvHelper.h
13613;0x352d;SUPV_ACK_FAILURE_REPORT;LOW;Supervisor received acknowledgment failure report P1: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h 13619;0x3533;SUPV_MISSING_ACK;LOW;Did not receive acknowledgement report P1: Number of bytes missing P2: Internal state of MPSoC helper;linux/devices/ploc/PlocSupvHelper.h
13614;0x352e;SUPV_EXE_FAILURE_REPORT;LOW;Execution report failure P1:;linux/devices/ploc/PlocSupvHelper.h 13620;0x3534;SUPV_MISSING_EXE;LOW;Supervisor did not receive execution report P1: Number of bytes missing P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h
13615;0x352f;SUPV_ACK_INVALID_APID;LOW;Supervisor expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h 13621;0x3535;SUPV_ACK_FAILURE_REPORT;LOW;Supervisor received acknowledgment failure report P1: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h
13616;0x3530;SUPV_EXE_INVALID_APID;LOW;Supervisor helper expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h 13622;0x3536;SUPV_EXE_FAILURE_REPORT;LOW;Execution report failure P1:;linux/devices/ploc/PlocSupvHelper.h
13617;0x3531;ACK_RECEPTION_FAILURE;LOW;Failed to receive acknowledgment report P1: Return value P2: Apid of command for which the reception of the acknowledgment report failed;linux/devices/ploc/PlocSupvHelper.h 13623;0x3537;SUPV_ACK_INVALID_APID;LOW;Supervisor expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h
13618;0x3532;EXE_RECEPTION_FAILURE;LOW;Failed to receive execution report P1: Return value P2: Apid of command for which the reception of the execution report failed;linux/devices/ploc/PlocSupvHelper.h 13624;0x3538;SUPV_EXE_INVALID_APID;LOW;Supervisor helper expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper;linux/devices/ploc/PlocSupvHelper.h
13619;0x3533;WRITE_MEMORY_FAILED;LOW;Update procedure failed when sending packet with number P1 P1: Packet number for which the memory write command fails;linux/devices/ploc/PlocSupvHelper.h 13625;0x3539;ACK_RECEPTION_FAILURE;LOW;Failed to receive acknowledgment report P1: Return value P2: Apid of command for which the reception of the acknowledgment report failed;linux/devices/ploc/PlocSupvHelper.h
13620;0x3534;SUPV_REPLY_SIZE_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h 13626;0x353a;EXE_RECEPTION_FAILURE;LOW;Failed to receive execution report P1: Return value P2: Apid of command for which the reception of the execution report failed;linux/devices/ploc/PlocSupvHelper.h
13621;0x3535;SUPV_REPLY_CRC_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h 13627;0x353b;WRITE_MEMORY_FAILED;LOW;Update procedure failed when sending packet. P1: First byte percent, third and fourth byte Sequence Count, P2: Bytes written;linux/devices/ploc/PlocSupvHelper.h
13628;0x353c;SUPV_REPLY_SIZE_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h
13629;0x353d;SUPV_REPLY_CRC_MISSMATCH;LOW;;linux/devices/ploc/PlocSupvHelper.h
13630;0x353e;SUPV_UPDATE_PROGRESS;INFO;Will be triggered every 5 percent of the update progress. P1: First byte percent, third and fourth byte Sequence Count, P2: Bytes written;linux/devices/ploc/PlocSupvHelper.h
13700;0x3584;ALLOC_FAILURE;MEDIUM;;bsp_q7s/core/CoreController.h 13700;0x3584;ALLOC_FAILURE;MEDIUM;;bsp_q7s/core/CoreController.h
13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h 13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h
13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h 13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h

1 Event ID (dec) Event ID (hex) Name Severity Description File Path
194 13607 13605 0x3527 0x3525 SUPV_EVENT_BUFFER_REQUEST_TERMINATED SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL LOW Terminated event buffer request by command P1: Number of packets read before process was terminated Requesting event buffer was successful linux/devices/ploc/PlocSupvHelper.h
195 13608 13606 0x3528 0x3526 SUPV_SENDING_COMMAND_FAILED SUPV_EVENT_BUFFER_REQUEST_FAILED LOW Requesting event buffer failed linux/devices/ploc/PlocSupvHelper.h
196 13609 13607 0x3529 0x3527 SUPV_HELPER_REQUESTING_REPLY_FAILED SUPV_EVENT_BUFFER_REQUEST_TERMINATED LOW Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of supervisor helper Terminated event buffer request by command P1: Number of packets read before process was terminated linux/devices/ploc/PlocSupvHelper.h
197 13610 13608 0x352a 0x3528 SUPV_HELPER_READING_REPLY_FAILED SUPV_MEM_CHECK_OK LOW INFO Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
198 13611 13609 0x352b 0x3529 SUPV_MISSING_ACK SUPV_MEM_CHECK_FAIL LOW INFO Did not receive acknowledgement report P1: Number of bytes missing P2: Internal state of MPSoC helper linux/devices/ploc/PlocSupvHelper.h
199 13612 13616 0x352c 0x3530 SUPV_MISSING_EXE SUPV_SENDING_COMMAND_FAILED LOW Supervisor did not receive execution report P1: Number of bytes missing P2: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
200 13613 13617 0x352d 0x3531 SUPV_ACK_FAILURE_REPORT SUPV_HELPER_REQUESTING_REPLY_FAILED LOW Supervisor received acknowledgment failure report P1: Internal state of supervisor helper Request receive message of communication interface failed P1: Return value returned by the communication interface requestReceiveMessage function P2: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
201 13614 13618 0x352e 0x3532 SUPV_EXE_FAILURE_REPORT SUPV_HELPER_READING_REPLY_FAILED LOW Execution report failure P1: Reading receive message of communication interface failed P1: Return value returned by the communication interface readingReceivedMessage function P2: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
202 13615 13619 0x352f 0x3533 SUPV_ACK_INVALID_APID SUPV_MISSING_ACK LOW Supervisor expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper Did not receive acknowledgement report P1: Number of bytes missing P2: Internal state of MPSoC helper linux/devices/ploc/PlocSupvHelper.h
203 13616 13620 0x3530 0x3534 SUPV_EXE_INVALID_APID SUPV_MISSING_EXE LOW Supervisor helper expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper Supervisor did not receive execution report P1: Number of bytes missing P2: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
204 13617 13621 0x3531 0x3535 ACK_RECEPTION_FAILURE SUPV_ACK_FAILURE_REPORT LOW Failed to receive acknowledgment report P1: Return value P2: Apid of command for which the reception of the acknowledgment report failed Supervisor received acknowledgment failure report P1: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
205 13618 13622 0x3532 0x3536 EXE_RECEPTION_FAILURE SUPV_EXE_FAILURE_REPORT LOW Failed to receive execution report P1: Return value P2: Apid of command for which the reception of the execution report failed Execution report failure P1: linux/devices/ploc/PlocSupvHelper.h
206 13619 13623 0x3533 0x3537 WRITE_MEMORY_FAILED SUPV_ACK_INVALID_APID LOW Update procedure failed when sending packet with number P1 P1: Packet number for which the memory write command fails Supervisor expected acknowledgment report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper linux/devices/ploc/PlocSupvHelper.h
207 13700 13624 0x3584 0x3538 ALLOC_FAILURE SUPV_EXE_INVALID_APID MEDIUM LOW Supervisor helper expected execution report but received space packet with other apid P1: Apid of received space packet P2: Internal state of supervisor helper bsp_q7s/core/CoreController.h linux/devices/ploc/PlocSupvHelper.h
208 13701 13625 0x3585 0x3539 REBOOT_SW ACK_RECEPTION_FAILURE MEDIUM LOW Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy Failed to receive acknowledgment report P1: Return value P2: Apid of command for which the reception of the acknowledgment report failed bsp_q7s/core/CoreController.h linux/devices/ploc/PlocSupvHelper.h
209 13702 13626 0x3586 0x353a REBOOT_MECHANISM_TRIGGERED EXE_RECEPTION_FAILURE MEDIUM LOW The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots Failed to receive execution report P1: Return value P2: Apid of command for which the reception of the execution report failed bsp_q7s/core/CoreController.h linux/devices/ploc/PlocSupvHelper.h
210 13703 13627 0x3587 0x353b REBOOT_HW WRITE_MEMORY_FAILED MEDIUM LOW Update procedure failed when sending packet. P1: First byte percent, third and fourth byte Sequence Count, P2: Bytes written bsp_q7s/core/CoreController.h linux/devices/ploc/PlocSupvHelper.h
211 13628 0x353c SUPV_REPLY_SIZE_MISSMATCH LOW linux/devices/ploc/PlocSupvHelper.h
212 13629 0x353d SUPV_REPLY_CRC_MISSMATCH LOW linux/devices/ploc/PlocSupvHelper.h
213 13630 0x353e SUPV_UPDATE_PROGRESS INFO Will be triggered every 5 percent of the update progress. P1: First byte percent, third and fourth byte Sequence Count, P2: Bytes written linux/devices/ploc/PlocSupvHelper.h
214 13700 0x3584 ALLOC_FAILURE MEDIUM bsp_q7s/core/CoreController.h
215 13701 0x3585 REBOOT_SW MEDIUM Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy bsp_q7s/core/CoreController.h
216 13702 0x3586 REBOOT_MECHANISM_TRIGGERED MEDIUM The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots bsp_q7s/core/CoreController.h

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 213 translations. * @brief Auto-generated event translation file. Contains 216 translations.
* @details * @details
* Generated on: 2022-08-18 11:23:13 * Generated on: 2022-08-24 16:44:18
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -196,6 +196,8 @@ const char *TERMINATED_UPDATE_PROCEDURE_STRING = "TERMINATED_UPDATE_PROCEDURE";
const char *SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL_STRING = "SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL"; const char *SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL_STRING = "SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL";
const char *SUPV_EVENT_BUFFER_REQUEST_FAILED_STRING = "SUPV_EVENT_BUFFER_REQUEST_FAILED"; const char *SUPV_EVENT_BUFFER_REQUEST_FAILED_STRING = "SUPV_EVENT_BUFFER_REQUEST_FAILED";
const char *SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING = "SUPV_EVENT_BUFFER_REQUEST_TERMINATED"; const char *SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING = "SUPV_EVENT_BUFFER_REQUEST_TERMINATED";
const char *SUPV_MEM_CHECK_OK_STRING = "SUPV_MEM_CHECK_OK";
const char *SUPV_MEM_CHECK_FAIL_STRING = "SUPV_MEM_CHECK_FAIL";
const char *SUPV_SENDING_COMMAND_FAILED_STRING = "SUPV_SENDING_COMMAND_FAILED"; const char *SUPV_SENDING_COMMAND_FAILED_STRING = "SUPV_SENDING_COMMAND_FAILED";
const char *SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING = "SUPV_HELPER_REQUESTING_REPLY_FAILED"; const char *SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING = "SUPV_HELPER_REQUESTING_REPLY_FAILED";
const char *SUPV_HELPER_READING_REPLY_FAILED_STRING = "SUPV_HELPER_READING_REPLY_FAILED"; const char *SUPV_HELPER_READING_REPLY_FAILED_STRING = "SUPV_HELPER_READING_REPLY_FAILED";
@ -210,6 +212,7 @@ const char *EXE_RECEPTION_FAILURE_STRING = "EXE_RECEPTION_FAILURE";
const char *WRITE_MEMORY_FAILED_STRING = "WRITE_MEMORY_FAILED"; const char *WRITE_MEMORY_FAILED_STRING = "WRITE_MEMORY_FAILED";
const char *SUPV_REPLY_SIZE_MISSMATCH_STRING = "SUPV_REPLY_SIZE_MISSMATCH"; const char *SUPV_REPLY_SIZE_MISSMATCH_STRING = "SUPV_REPLY_SIZE_MISSMATCH";
const char *SUPV_REPLY_CRC_MISSMATCH_STRING = "SUPV_REPLY_CRC_MISSMATCH"; const char *SUPV_REPLY_CRC_MISSMATCH_STRING = "SUPV_REPLY_CRC_MISSMATCH";
const char *SUPV_UPDATE_PROGRESS_STRING = "SUPV_UPDATE_PROGRESS";
const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE";
const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_SW_STRING = "REBOOT_SW";
const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED";
@ -600,33 +603,39 @@ const char *translateEvents(Event event) {
case (13607): case (13607):
return SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING; return SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING;
case (13608): case (13608):
return SUPV_SENDING_COMMAND_FAILED_STRING; return SUPV_MEM_CHECK_OK_STRING;
case (13609): case (13609):
return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING; return SUPV_MEM_CHECK_FAIL_STRING;
case (13610):
return SUPV_HELPER_READING_REPLY_FAILED_STRING;
case (13611):
return SUPV_MISSING_ACK_STRING;
case (13612):
return SUPV_MISSING_EXE_STRING;
case (13613):
return SUPV_ACK_FAILURE_REPORT_STRING;
case (13614):
return SUPV_EXE_FAILURE_REPORT_STRING;
case (13615):
return SUPV_ACK_INVALID_APID_STRING;
case (13616): case (13616):
return SUPV_EXE_INVALID_APID_STRING; return SUPV_SENDING_COMMAND_FAILED_STRING;
case (13617): case (13617):
return ACK_RECEPTION_FAILURE_STRING; return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING;
case (13618): case (13618):
return EXE_RECEPTION_FAILURE_STRING; return SUPV_HELPER_READING_REPLY_FAILED_STRING;
case (13619): case (13619):
return WRITE_MEMORY_FAILED_STRING; return SUPV_MISSING_ACK_STRING;
case (13620): case (13620):
return SUPV_REPLY_SIZE_MISSMATCH_STRING; return SUPV_MISSING_EXE_STRING;
case (13621): case (13621):
return SUPV_ACK_FAILURE_REPORT_STRING;
case (13622):
return SUPV_EXE_FAILURE_REPORT_STRING;
case (13623):
return SUPV_ACK_INVALID_APID_STRING;
case (13624):
return SUPV_EXE_INVALID_APID_STRING;
case (13625):
return ACK_RECEPTION_FAILURE_STRING;
case (13626):
return EXE_RECEPTION_FAILURE_STRING;
case (13627):
return WRITE_MEMORY_FAILED_STRING;
case (13628):
return SUPV_REPLY_SIZE_MISSMATCH_STRING;
case (13629):
return SUPV_REPLY_CRC_MISSMATCH_STRING; return SUPV_REPLY_CRC_MISSMATCH_STRING;
case (13630):
return SUPV_UPDATE_PROGRESS_STRING;
case (13700): case (13700):
return ALLOC_FAILURE_STRING; return ALLOC_FAILURE_STRING;
case (13701): case (13701):

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 133 translations. * Contains 133 translations.
* Generated on: 2022-08-18 11:23:13 * Generated on: 2022-08-24 16:44:18
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -143,7 +143,7 @@ class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
virtual ~TcBase() = default; virtual ~TcBase() = default;
// Initial length field of space packet. Will always be updated when packet is created. // Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = 1; static const uint16_t INIT_LENGTH = 2;
/** /**
* @brief Constructor * @brief Constructor

View File

@ -60,6 +60,7 @@ static const DeviceCommandId_t REQUEST_ADC_REPORT = 57;
static const DeviceCommandId_t RESET_PL = 58; static const DeviceCommandId_t RESET_PL = 58;
static const DeviceCommandId_t ENABLE_NVMS = 59; static const DeviceCommandId_t ENABLE_NVMS = 59;
static const DeviceCommandId_t CONTINUE_UPDATE = 60; static const DeviceCommandId_t CONTINUE_UPDATE = 60;
static const DeviceCommandId_t MEMORY_CHECK_WITH_FILE = 61;
/** Reply IDs */ /** Reply IDs */
static const DeviceCommandId_t ACK_REPORT = 100; static const DeviceCommandId_t ACK_REPORT = 100;
@ -159,6 +160,15 @@ static const size_t MAX_PACKET_SIZE = 1024;
static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6; static const uint8_t SPACE_PACKET_HEADER_LENGTH = 6;
struct UpdateParams {
std::string file;
uint8_t memId;
uint32_t startAddr;
uint32_t bytesWritten;
uint16_t seqCount;
bool deleteMemory;
};
enum PoolIds : lp_id_t { enum PoolIds : lp_id_t {
NUM_TMS, NUM_TMS,
TEMP_PS, TEMP_PS,
@ -1150,7 +1160,7 @@ class WriteMemory : public ploc::SpTcBase {
}; };
/** /**
* @brief This class can be used to package the update available or update verify command. * @brief This class can be used to package erase memory command
*/ */
class EraseMemory : public ploc::SpTcBase { class EraseMemory : public ploc::SpTcBase {
public: public:
@ -1246,11 +1256,14 @@ class DisableAutoTm : public ploc::SpTcBase {
*/ */
class RequestLoggingData : public ploc::SpTcBase { class RequestLoggingData : public ploc::SpTcBase {
public: public:
/**
* Subapid
*/
enum class Sa : uint8_t { enum class Sa : uint8_t {
REQUEST_COUNTERS = 1, REQUEST_COUNTERS = 1, /**< REQUEST_COUNTERS */
REQUEST_EVENT_BUFFERS = 2, REQUEST_EVENT_BUFFERS = 2, /**< REQUEST_EVENT_BUFFERS */
CLEAR_COUNTERS = 3, CLEAR_COUNTERS = 3, /**< CLEAR_COUNTERS */
SET_LOGGING_TOPIC = 4 SET_LOGGING_TOPIC = 4 /**< SET_LOGGING_TOPIC */
}; };
RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) { RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) {
@ -1259,6 +1272,11 @@ class RequestLoggingData : public ploc::SpTcBase {
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
} }
/**
* @param sa
* @param tpc Topic
* @return
*/
ReturnValue_t buildPacket(Sa sa, uint8_t tpc = 0) { ReturnValue_t buildPacket(Sa sa, uint8_t tpc = 0) {
auto res = checkSizeAndSerializeHeader(); auto res = checkSizeAndSerializeHeader();
if (res != result::OK) { if (res != result::OK) {
@ -1658,7 +1676,8 @@ class ExecutionReport : public VerificationReport {
} }
default: default:
sif::warning << "ExecutionReport::printStatusInformation: Invalid status code: 0x" sif::warning << "ExecutionReport::printStatusInformation: Invalid status code: 0x"
<< std::hex << static_cast<uint16_t>(statusCode) << std::endl; << std::hex << std::setfill('0') << std::setw(4)
<< static_cast<uint16_t>(statusCode) << std::dec << std::endl;
break; break;
} }
} }
@ -1829,20 +1848,13 @@ class UpdateStatusReport : public ploc::SpTmReader {
return result; return result;
} }
const uint8_t* dataFieldPtr = getFullData() + ccsds::HEADER_LEN; const uint8_t* dataFieldPtr = getFullData() + ccsds::HEADER_LEN;
size_t size = sizeof(memoryId); size_t size = 12;
SerializeAdapter::deSerialize(&memoryId, dataFieldPtr, &size, SerializeIF::Endianness::BIG); SerializeAdapter::deSerialize(&memoryId, &dataFieldPtr, &size, SerializeIF::Endianness::BIG);
dataFieldPtr += size; SerializeAdapter::deSerialize(&n, &dataFieldPtr, &size, SerializeIF::Endianness::BIG);
size = sizeof(n); SerializeAdapter::deSerialize(&startAddress, &dataFieldPtr, &size,
SerializeAdapter::deSerialize(&n, dataFieldPtr, &size, SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
dataFieldPtr += size; SerializeAdapter::deSerialize(&length, &dataFieldPtr, &size, SerializeIF::Endianness::BIG);
size = sizeof(startAddress); SerializeAdapter::deSerialize(&crc, &dataFieldPtr, &size, SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&startAddress, dataFieldPtr, &size, SerializeIF::Endianness::BIG);
dataFieldPtr += size;
size = sizeof(length);
SerializeAdapter::deSerialize(&length, dataFieldPtr, &size, SerializeIF::Endianness::BIG);
dataFieldPtr += size;
size = sizeof(crc);
SerializeAdapter::deSerialize(&crc, dataFieldPtr, &size, SerializeIF::Endianness::BIG);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -410,7 +410,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcMemWrite.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -424,7 +424,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcMemRead.getFullPacketLen());
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE; tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
return RETURN_OK; return RETURN_OK;
} }
@ -443,7 +443,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcFlashDelete.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -457,7 +457,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcReplayStart.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -470,7 +470,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcReplayStop.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -484,7 +484,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcDownlinkPwrOn.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -497,7 +497,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcDownlinkPwrOff.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -511,7 +511,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcReplayWriteSeq.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -524,7 +524,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcModeReplay.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -537,7 +537,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcModeIdle.getFullPacketLen());
return RETURN_OK; return RETURN_OK;
} }
@ -551,17 +551,19 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
sequenceCount--; sequenceCount--;
return result; return result;
} }
finishTcPrep(); finishTcPrep(tcCamCmdSend.getFullPacketLen());
nextReplyId = mpsoc::TM_CAM_CMD_RPT; nextReplyId = mpsoc::TM_CAM_CMD_RPT;
return RETURN_OK; return RETURN_OK;
} }
void PlocMPSoCHandler::finishTcPrep() { nextReplyId = mpsoc::ACK_REPORT; } void PlocMPSoCHandler::finishTcPrep(size_t packetLen) {
nextReplyId = mpsoc::ACK_REPORT;
rawPacket = commandBuffer;
rawPacketLen = packetLen;
}
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); if (CRC::crc16ccitt(start, foundLen) != 0) {
uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2);
if (receivedCrc != recalculatedCrc) {
return MPSoCReturnValuesIF::CRC_FAILURE; return MPSoCReturnValuesIF::CRC_FAILURE;
} }
return RETURN_OK; return RETURN_OK;

View File

@ -172,7 +172,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcModeIdle(); ReturnValue_t prepareTcModeIdle();
void finishTcPrep(); void finishTcPrep(size_t packetLen);
/** /**
* @brief This function checks the crc of the received PLOC reply. * @brief This function checks the crc of the received PLOC reply.

View File

@ -1,5 +1,7 @@
#include "PlocSupervisorHandler.h" #include "PlocSupervisorHandler.h"
#include <fsfw/memory/HasFileSystemIF.h>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
@ -104,19 +106,22 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
return SupvReturnValuesIF::SUPV_HELPER_EXECUTING; return SupvReturnValuesIF::SUPV_HELPER_EXECUTING;
} }
result = acceptExternalDeviceCommands();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
switch (actionId) { switch (actionId) {
case PERFORM_UPDATE: { case PERFORM_UPDATE: {
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) { if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return SupvReturnValuesIF::FILENAME_TOO_LONG; return SupvReturnValuesIF::FILENAME_TOO_LONG;
} }
std::string file = ""; UpdateParams params;
uint8_t memoryId = 0; result = extractUpdateCommand(data, size, params);
uint32_t startAddress = 0;
result = extractUpdateCommand(data, size, &file, &memoryId, &startAddress);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = supvHelper->startUpdate(file, memoryId, startAddress); result = supvHelper->performUpdate(params);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -128,6 +133,19 @@ ReturnValue_t PlocSupervisorHandler::executeAction(ActionId_t actionId,
plocSupvHelperExecuting = true; plocSupvHelperExecuting = true;
return EXECUTION_FINISHED; return EXECUTION_FINISHED;
} }
case MEMORY_CHECK_WITH_FILE: {
UpdateParams params;
ReturnValue_t result = extractBaseParams(&data, size, params);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (not std::filesystem::exists(params.file)) {
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
}
supvHelper->performMemCheck(params.file, params.memId, params.startAddr);
plocSupvHelperExecuting = true;
return EXECUTION_FINISHED;
}
case LOGGING_REQUEST_EVENT_BUFFERS: { case LOGGING_REQUEST_EVENT_BUFFERS: {
if (size > config::MAX_PATH_SIZE) { if (size > config::MAX_PATH_SIZE) {
return SupvReturnValuesIF::FILENAME_TOO_LONG; return SupvReturnValuesIF::FILENAME_TOO_LONG;
@ -858,7 +876,9 @@ void PlocSupervisorHandler::handleEvent(EventMessage* eventMessage) {
if (event == PlocSupvHelper::SUPV_UPDATE_FAILED || if (event == PlocSupvHelper::SUPV_UPDATE_FAILED ||
event == PlocSupvHelper::SUPV_UPDATE_SUCCESSFUL || event == PlocSupvHelper::SUPV_UPDATE_SUCCESSFUL ||
event == PlocSupvHelper::SUPV_CONTINUE_UPDATE_FAILED || event == PlocSupvHelper::SUPV_CONTINUE_UPDATE_FAILED ||
event == PlocSupvHelper::SUPV_CONTINUE_UPDATE_SUCCESSFUL) { event == PlocSupvHelper::SUPV_CONTINUE_UPDATE_SUCCESSFUL ||
event == PlocSupvHelper::SUPV_MEM_CHECK_FAIL ||
event == PlocSupvHelper::SUPV_MEM_CHECK_OK) {
result = this->executeAction(supv::SHUTDOWN_MPSOC, NO_COMMANDER, nullptr, 0); result = this->executeAction(supv::SHUTDOWN_MPSOC, NO_COMMANDER, nullptr, 0);
if (result != RETURN_OK) { if (result != RETURN_OK) {
triggerEvent(SUPV_MPSOC_SHUWDOWN_BUILD_FAILED); triggerEvent(SUPV_MPSOC_SHUWDOWN_BUILD_FAILED);
@ -1044,6 +1064,7 @@ ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) {
offset += 1; offset += 1;
nextReplyId = supv::EXE_REPORT; nextReplyId = supv::EXE_REPORT;
hkset.setValidity(true, true);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1
sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl;
@ -1106,6 +1127,7 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data)
bootStatusReport.bootCycles = *(data + offset); bootStatusReport.bootCycles = *(data + offset);
nextReplyId = supv::EXE_REPORT; nextReplyId = supv::EXE_REPORT;
bootStatusReport.setValidity(true, true);
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1
sif::info << "PlocSupervisorHandler::handleBootStatusReport: SoC State (0 - off, 1 - booting, 2 " sif::info << "PlocSupervisorHandler::handleBootStatusReport: SoC State (0 - off, 1 - booting, 2 "
@ -1969,34 +1991,78 @@ ReturnValue_t PlocSupervisorHandler::getTimeStampString(std::string& timeStamp)
} }
ReturnValue_t PlocSupervisorHandler::extractUpdateCommand(const uint8_t* commandData, size_t size, ReturnValue_t PlocSupervisorHandler::extractUpdateCommand(const uint8_t* commandData, size_t size,
std::string* file, uint8_t* memoryId, supv::UpdateParams& params) {
uint32_t* startAddress) { size_t remSize = size;
ReturnValue_t result = RETURN_OK; if (size > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE + sizeof(params.memId)) +
if (size > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE + sizeof(*memoryId)) + sizeof(params.startAddr) + sizeof(params.bytesWritten) + sizeof(params.seqCount) +
sizeof(*startAddress)) { sizeof(uint8_t)) {
sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Data size too big" << std::endl; sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Data size too big" << std::endl;
return SupvReturnValuesIF::INVALID_LENGTH; return SupvReturnValuesIF::INVALID_LENGTH;
} }
*file = std::string(reinterpret_cast<const char*>(commandData)); ReturnValue_t result = RETURN_OK;
if (file->size() > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE)) { result = extractBaseParams(&commandData, size, params);
sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Filename too long" << std::endl; result = SerializeAdapter::deSerialize(&params.bytesWritten, &commandData, &remSize,
return SupvReturnValuesIF::FILENAME_TOO_LONG; SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Failed to deserialize bytes "
"already written"
<< std::endl;
return result;
} }
*memoryId = *(commandData + file->size() + SIZE_NULL_TERMINATOR); result = SerializeAdapter::deSerialize(&params.seqCount, &commandData, &remSize,
const uint8_t* startAddressPtr =
commandData + file->size() + SIZE_NULL_TERMINATOR + sizeof(*memoryId);
size_t remainingSize = 4;
result = SerializeAdapter::deSerialize(startAddress, startAddressPtr, &remainingSize,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning sif::warning
<< "PlocSupervisorHandler::extractUpdateCommand: Failed to deserialize start address" << "PlocSupervisorHandler::extractUpdateCommand: Failed to deserialize start sequence count"
<< std::endl; << std::endl;
return result; return result;
} }
uint8_t delMemRaw = 0;
result = SerializeAdapter::deSerialize(&delMemRaw, &commandData, &remSize,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning
<< "PlocSupervisorHandler::extractUpdateCommand: Failed to deserialize whether to delete "
"memory"
<< std::endl;
return result;
}
params.deleteMemory = delMemRaw;
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocSupervisorHandler::extractBaseParams(const uint8_t** commandData, size_t& remSize,
supv::UpdateParams& params) {
bool nullTermFound = false;
for (size_t idx = 0; idx < remSize; idx++) {
if ((*commandData)[idx] == '\0') {
nullTermFound = true;
break;
}
}
if (not nullTermFound) {
return HasReturnvaluesIF::RETURN_FAILED;
}
params.file = std::string(reinterpret_cast<const char*>(*commandData));
if (params.file.size() > (config::MAX_FILENAME_SIZE + config::MAX_PATH_SIZE)) {
sif::warning << "PlocSupervisorHandler::extractUpdateCommand: Filename too long" << std::endl;
return SupvReturnValuesIF::FILENAME_TOO_LONG;
}
*commandData += params.file.size() + SIZE_NULL_TERMINATOR;
remSize -= (params.file.size() + SIZE_NULL_TERMINATOR);
params.memId = **commandData;
*commandData += 1;
remSize -= 1;
ReturnValue_t result = SerializeAdapter::deSerialize(&params.startAddr, commandData, &remSize,
SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
sif::warning << "PlocSupervisorHandler::extractBaseParams: Failed to deserialize start address"
<< std::endl;
return result;
}
return result;
}
ReturnValue_t PlocSupervisorHandler::eventSubscription() { ReturnValue_t PlocSupervisorHandler::eventSubscription() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER); EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
@ -2011,9 +2077,9 @@ ReturnValue_t PlocSupervisorHandler::eventSubscription() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = manager->subscribeToEventRange( result = manager->subscribeToEventRange(eventQueue->getId(),
eventQueue->getId(), event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED), event::getEventId(PlocSupvHelper::SUPV_UPDATE_FAILED),
event::getEventId(PlocSupvHelper::SUPV_EVENT_BUFFER_REQUEST_TERMINATED)); event::getEventId(PlocSupvHelper::SUPV_MEM_CHECK_FAIL));
if (result != RETURN_OK) { if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PlocSupervisorHandler::eventSubscritpion: Failed to subscribe to events from " sif::warning << "PlocSupervisorHandler::eventSubscritpion: Failed to subscribe to events from "

View File

@ -367,8 +367,10 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
ReturnValue_t prepareSetShutdownTimeoutCmd(const uint8_t* commandData); ReturnValue_t prepareSetShutdownTimeoutCmd(const uint8_t* commandData);
ReturnValue_t extractUpdateCommand(const uint8_t* commandData, size_t size, std::string* file, ReturnValue_t extractUpdateCommand(const uint8_t* commandData, size_t size,
uint8_t* memoryId, uint32_t* startAddress); supv::UpdateParams& params);
ReturnValue_t extractBaseParams(const uint8_t** commandData, size_t& remSize,
supv::UpdateParams& params);
ReturnValue_t eventSubscription(); ReturnValue_t eventSubscription();
ReturnValue_t handleExecutionSuccessReport(const uint8_t* data); ReturnValue_t handleExecutionSuccessReport(const uint8_t* data);

View File

@ -1,5 +1,8 @@
#include "PlocSupvHelper.h" #include "PlocSupvHelper.h"
#include <etl/crc16_ccitt.h>
#include <cmath>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
@ -9,7 +12,6 @@
#include "bsp_q7s/memory/SdCardManager.h" #include "bsp_q7s/memory/SdCardManager.h"
#endif #endif
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "fsfw/timemanager/Countdown.h" #include "fsfw/timemanager/Countdown.h"
#include "mission/utility/Filenaming.h" #include "mission/utility/Filenaming.h"
@ -44,7 +46,7 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
break; break;
} }
case InternalState::UPDATE: { case InternalState::UPDATE: {
result = performUpdate(); result = executeUpdate();
if (result == RETURN_OK) { if (result == RETURN_OK) {
triggerEvent(SUPV_UPDATE_SUCCESSFUL, result); triggerEvent(SUPV_UPDATE_SUCCESSFUL, result);
} else if (result == PROCESS_TERMINATED) { } else if (result == PROCESS_TERMINATED) {
@ -55,6 +57,11 @@ ReturnValue_t PlocSupvHelper::performOperation(uint8_t operationCode) {
internalState = InternalState::IDLE; internalState = InternalState::IDLE;
break; break;
} }
case InternalState::CHECK_MEMORY: {
executeFullCheckMemoryCommand();
internalState = InternalState::IDLE;
break;
}
case InternalState::CONTINUE_UPDATE: { case InternalState::CONTINUE_UPDATE: {
result = continueUpdate(); result = continueUpdate();
if (result == RETURN_OK) { if (result == RETURN_OK) {
@ -100,16 +107,28 @@ void PlocSupvHelper::setComCookie(CookieIF* comCookie_) { comCookie = comCookie_
ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId, ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
uint32_t startAddress) { uint32_t startAddress) {
supv::UpdateParams params;
params.file = file;
params.memId = memoryId;
params.startAddr = startAddress;
params.bytesWritten = 0;
params.seqCount = 1;
params.deleteMemory = true;
return performUpdate(params);
}
ReturnValue_t PlocSupvHelper::performUpdate(const supv::UpdateParams& params) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
result = FilesystemHelper::checkPath(file); result = FilesystemHelper::checkPath(params.file);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::startUpdate: File " << file << " does not exist" << std::endl; sif::warning << "PlocSupvHelper::startUpdate: File " << params.file << " does not exist"
<< std::endl;
return result; return result;
} }
result = FilesystemHelper::fileExists(file); result = FilesystemHelper::fileExists(params.file);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::startUpdate: The file " << file << " does not exist" sif::warning << "PlocSupvHelper::startUpdate: The file " << params.file << " does not exist"
<< std::endl; << std::endl;
return result; return result;
} }
@ -121,20 +140,47 @@ ReturnValue_t PlocSupvHelper::startUpdate(std::string file, uint8_t memoryId,
return RETURN_FAILED; return RETURN_FAILED;
} }
#endif #endif
update.file = file; update.file = params.file;
update.length = getFileSize(update.file); update.fullFileSize = getFileSize(update.file);
update.memoryId = memoryId; if (params.bytesWritten > update.fullFileSize) {
update.startAddress = startAddress; sif::warning << "Invalid start bytes counter " << params.bytesWritten
update.remainingSize = update.length; << ", smaller than full file length" << update.fullFileSize << std::endl;
update.bytesWritten = 0; return HasReturnvaluesIF::RETURN_FAILED;
}
update.length = update.fullFileSize - params.bytesWritten;
update.memoryId = params.memId;
update.startAddress = params.startAddr;
update.progressPercent = 0;
update.bytesWritten = params.bytesWritten;
update.crcShouldBeChecked = true;
update.packetNum = 1; update.packetNum = 1;
update.sequenceCount = 1; update.deleteMemory = params.deleteMemory;
update.sequenceCount = params.seqCount;
internalState = InternalState::UPDATE; internalState = InternalState::UPDATE;
uartComIF->flushUartTxAndRxBuf(comCookie); uartComIF->flushUartTxAndRxBuf(comCookie);
semaphore.release(); semaphore.release();
return result; return result;
} }
ReturnValue_t PlocSupvHelper::performMemCheck(std::string file, uint8_t memoryId,
uint32_t startAddress) {
update.file = file;
update.fullFileSize = getFileSize(file);
return performMemCheck(memoryId, startAddress, getFileSize(update.file), true);
}
ReturnValue_t PlocSupvHelper::performMemCheck(uint8_t memoryId, uint32_t startAddress,
size_t sizeToCheck, bool checkCrc) {
update.memoryId = memoryId;
update.startAddress = startAddress;
update.length = sizeToCheck;
update.crcShouldBeChecked = checkCrc;
internalState = InternalState::CHECK_MEMORY;
uartComIF->flushUartTxAndRxBuf(comCookie);
semaphore.release();
return HasReturnvaluesIF::RETURN_OK;
}
void PlocSupvHelper::initiateUpdateContinuation() { void PlocSupvHelper::initiateUpdateContinuation() {
internalState = InternalState::CONTINUE_UPDATE; internalState = InternalState::CONTINUE_UPDATE;
semaphore.release(); semaphore.release();
@ -159,39 +205,62 @@ ReturnValue_t PlocSupvHelper::startEventbBufferRequest(std::string path) {
void PlocSupvHelper::stopProcess() { terminate = true; } void PlocSupvHelper::stopProcess() { terminate = true; }
ReturnValue_t PlocSupvHelper::performUpdate() { void PlocSupvHelper::executeFullCheckMemoryCommand() {
ReturnValue_t result;
if (update.crcShouldBeChecked) {
sif::info << "PLOC SUPV Mem Check: Calculating Image CRC" << std::endl;
result = calcImageCrc();
if (result != RETURN_OK) {
triggerEvent(SUPV_MEM_CHECK_FAIL, result);
return;
}
}
sif::info << "PLOC SUPV Mem Check: Selecting Memory" << std::endl;
result = selectMemory();
if (result != RETURN_OK) {
triggerEvent(SUPV_MEM_CHECK_FAIL, result);
return;
}
sif::info << "PLOC SUPV Mem Check: Preparing Update" << std::endl;
result = prepareUpdate();
if (result != RETURN_OK) {
triggerEvent(SUPV_MEM_CHECK_FAIL, result);
return;
}
sif::info << "PLOC SUPV Mem Check: Memory Check" << std::endl;
result = handleCheckMemoryCommand();
if (result == HasReturnvaluesIF::RETURN_OK) {
triggerEvent(SUPV_MEM_CHECK_OK, result);
} else {
triggerEvent(SUPV_MEM_CHECK_FAIL, result);
}
}
ReturnValue_t PlocSupvHelper::executeUpdate() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
sif::info << "PlocSupvHelper::performUpdate: Calculating Image CRC" << std::endl; sif::info << "PLOC SUPV Update MPSoC: Calculating Image CRC" << std::endl;
result = calcImageCrc(); result = calcImageCrc();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
sif::info << "PlocSupvHelper::performUpdate: Selecting Memory" << std::endl; sif::info << "PLOC SUPV Update MPSoC: Selecting Memory" << std::endl;
result = selectMemory(); result = selectMemory();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
sif::info << "PlocSupvHelper::performUpdate: Preparing Update" << std::endl; sif::info << "PLOC SUPV Update MPSoC: Preparing Update" << std::endl;
result = prepareUpdate(); result = prepareUpdate();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
sif::info << "PlocSupvHelper::performUpdate: Erasing Memory" << std::endl; if (update.deleteMemory) {
result = eraseMemory(); sif::info << "PLOC SUPV Update MPSoC: Erasing Memory" << std::endl;
if (result != RETURN_OK) { result = eraseMemory();
return result; if (result != RETURN_OK) {
return result;
}
} }
sif::info << "PlocSupvHelper::performUpdate: Writing Update Packets" << std::endl; return updateOperation();
result = writeUpdatePackets();
if (result != RETURN_OK) {
return result;
}
sif::info << "PlocSupvHelper::performUpdate: Memory Check" << std::endl;
result = handleCheckMemoryCommand();
if (result != RETURN_OK) {
return result;
}
return result;
} }
ReturnValue_t PlocSupvHelper::continueUpdate() { ReturnValue_t PlocSupvHelper::continueUpdate() {
@ -199,40 +268,45 @@ ReturnValue_t PlocSupvHelper::continueUpdate() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = writeUpdatePackets(); return updateOperation();
}
ReturnValue_t PlocSupvHelper::updateOperation() {
sif::info << "PlocSupvHelper::performUpdate: Writing Update Packets" << std::endl;
auto result = writeUpdatePackets();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = handleCheckMemoryCommand(); sif::info << "PlocSupvHelper::performUpdate: Memory Check" << std::endl;
if (result != RETURN_OK) { return handleCheckMemoryCommand();
return result;
}
return result;
} }
ReturnValue_t PlocSupvHelper::writeUpdatePackets() { ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
ProgressPrinter progressPrinter("Supervisor update", update.length, ProgressPrinter progressPrinter("Supervisor update", update.fullFileSize,
ProgressPrinter::HALF_PERCENT); ProgressPrinter::HALF_PERCENT);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint8_t tempData[supv::WriteMemory::CHUNK_MAX]; uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{};
std::ifstream file(update.file, std::ifstream::binary); std::ifstream file(update.file, std::ifstream::binary);
uint16_t dataLength = 0; uint16_t dataLength = 0;
ccsds::SequenceFlags seqFlags; ccsds::SequenceFlags seqFlags;
while (update.remainingSize > 0) { while (update.bytesWritten < update.fullFileSize) {
if (terminate) { if (terminate) {
terminate = false; terminate = false;
triggerEvent(TERMINATED_UPDATE_PROCEDURE); triggerEvent(TERMINATED_UPDATE_PROCEDURE);
return PROCESS_TERMINATED; return PROCESS_TERMINATED;
} }
if (update.remainingSize > supv::WriteMemory::CHUNK_MAX) { size_t remainingSize = update.fullFileSize - update.bytesWritten;
bool lastSegment = false;
if (remainingSize > supv::WriteMemory::CHUNK_MAX) {
dataLength = supv::WriteMemory::CHUNK_MAX; dataLength = supv::WriteMemory::CHUNK_MAX;
} else { } else {
dataLength = static_cast<uint16_t>(update.remainingSize); lastSegment = true;
dataLength = static_cast<uint16_t>(remainingSize);
} }
if (file.is_open()) { if (file.is_open()) {
file.seekg(update.bytesWritten, file.beg); file.seekg(update.bytesWritten, std::ios::beg);
file.read(reinterpret_cast<char*>(tempData), dataLength); file.read(reinterpret_cast<char*>(tempData), dataLength);
if (!file) { if (!file) {
sif::warning << "PlocSupvHelper::performUpdate: Read only " << file.gcount() << " of " sif::warning << "PlocSupvHelper::performUpdate: Read only " << file.gcount() << " of "
@ -245,29 +319,40 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
} }
if (update.bytesWritten == 0) { if (update.bytesWritten == 0) {
seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT; seqFlags = ccsds::SequenceFlags::FIRST_SEGMENT;
} else if (update.remainingSize == 0) { } else if (lastSegment) {
seqFlags = ccsds::SequenceFlags::LAST_SEGMENT; seqFlags = ccsds::SequenceFlags::LAST_SEGMENT;
} else { } else {
seqFlags = ccsds::SequenceFlags::CONTINUATION; seqFlags = ccsds::SequenceFlags::CONTINUATION;
} }
resetSpParams(); resetSpParams();
float progress = static_cast<float>(update.bytesWritten) / update.fullFileSize;
uint8_t progPercent = std::floor(progress * 100);
if (progPercent > update.progressPercent) {
update.progressPercent = progPercent;
if (progPercent % 5 == 0) {
// Useful to allow restarting the update
triggerEvent(SUPV_UPDATE_PROGRESS, buildProgParams1(progPercent, update.sequenceCount),
update.bytesWritten);
}
}
supv::WriteMemory packet(spParams); supv::WriteMemory packet(spParams);
result = packet.buildPacket(seqFlags, update.sequenceCount++, update.memoryId, result = packet.buildPacket(seqFlags, update.sequenceCount, update.memoryId,
update.startAddress + update.bytesWritten, dataLength, tempData); update.startAddress + update.bytesWritten, dataLength, tempData);
if (result != RETURN_OK) { if (result != RETURN_OK) {
update.sequenceCount--; triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount),
triggerEvent(WRITE_MEMORY_FAILED, update.packetNum); update.bytesWritten);
return result; return result;
} }
result = handlePacketTransmission(packet); result = handlePacketTransmission(packet);
if (result != RETURN_OK) { if (result != RETURN_OK) {
update.sequenceCount--; triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount),
triggerEvent(WRITE_MEMORY_FAILED, update.packetNum); update.bytesWritten);
return result; return result;
} }
update.remainingSize -= dataLength; update.sequenceCount++;
update.packetNum += 1; update.packetNum += 1;
update.bytesWritten += dataLength; update.bytesWritten += dataLength;
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
progressPrinter.print(update.bytesWritten); progressPrinter.print(update.bytesWritten);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
@ -275,6 +360,10 @@ ReturnValue_t PlocSupvHelper::writeUpdatePackets() {
return result; return result;
} }
uint32_t PlocSupvHelper::buildProgParams1(uint8_t percent, uint16_t seqCount) {
return (static_cast<uint32_t>(percent) << 24) | static_cast<uint32_t>(seqCount);
}
ReturnValue_t PlocSupvHelper::performEventBufferRequest() { ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
using namespace supv; using namespace supv;
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
@ -292,13 +381,38 @@ ReturnValue_t PlocSupvHelper::performEventBufferRequest() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = handleEventBufferReception(); result =
handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), supv::recv_timeout::UPDATE_STATUS_REPORT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = handleExe(); ploc::SpTmReader spReader(tmBuf.data(), tmBuf.size());
if (result != RETURN_OK) { bool exeAlreadyReceived = false;
return result; if (spReader.getApid() == supv::APID_EXE_FAILURE) {
exeAlreadyReceived = true;
result = handleRemainingExeReport(spReader);
} else if (spReader.getApid() == supv::APID_MRAM_DUMP_TM) {
result = handleEventBufferReception(spReader);
}
if (not exeAlreadyReceived) {
result = handleExe();
if (result != RETURN_OK) {
return result;
}
}
return result;
}
ReturnValue_t PlocSupvHelper::handleRemainingExeReport(ploc::SpTmReader& reader) {
size_t remBytes = reader.getPacketDataLen() + 1;
ReturnValue_t result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Reading exe failure report failed" << std::endl;
}
result = exeReportHandling();
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Handling exe report failed" << std::endl;
} }
return result; return result;
} }
@ -337,7 +451,8 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
resetSpParams(); resetSpParams();
supv::EraseMemory eraseMemory(spParams); supv::EraseMemory eraseMemory(spParams);
result = eraseMemory.buildPacket(update.memoryId, update.startAddress, update.length); result = eraseMemory.buildPacket(update.memoryId, update.startAddress + update.bytesWritten,
update.length);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -408,15 +523,21 @@ ReturnValue_t PlocSupvHelper::handleAck() {
ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) { ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = handleTmReception(supv::SIZE_EXE_REPORT, timeout); result = handleTmReception(supv::SIZE_EXE_REPORT, tmBuf.data(), timeout);
if (result != RETURN_OK) { if (result != RETURN_OK) {
triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid)); triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report" sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report"
<< std::endl; << std::endl;
return result; return result;
} }
return exeReportHandling();
}
ReturnValue_t PlocSupvHelper::exeReportHandling() {
supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size()); supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size());
result = checkReceivedTm(exeReport);
ReturnValue_t result = checkReceivedTm(exeReport);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -429,16 +550,20 @@ ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
} }
return result; return result;
} }
return RETURN_OK; return result;
} }
ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint32_t timeout) { ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint8_t* readBuf,
uint32_t timeout) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
size_t readBytes = 0; size_t readBytes = 0;
size_t currentBytes = 0; size_t currentBytes = 0;
Countdown countdown(timeout); Countdown countdown(timeout);
if (readBuf == nullptr) {
readBuf = tmBuf.data();
}
while (!countdown.hasTimedOut()) { while (!countdown.hasTimedOut()) {
result = receive(tmBuf.data() + readBytes, &currentBytes, remainingBytes); result = receive(readBuf + readBytes, &currentBytes, remainingBytes);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -450,7 +575,7 @@ ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint32_t
} }
if (remainingBytes != 0) { if (remainingBytes != 0) {
sif::warning << "PlocSupvHelper::handleTmReception: Failed to read " << std::dec sif::warning << "PlocSupvHelper::handleTmReception: Failed to read " << std::dec
<< remainingBytes << " bytes" << std::endl; << remainingBytes << " remaining bytes" << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} }
return result; return result;
@ -496,44 +621,59 @@ ReturnValue_t PlocSupvHelper::receive(uint8_t* data, size_t* readBytes, size_t r
ReturnValue_t PlocSupvHelper::calcImageCrc() { ReturnValue_t PlocSupvHelper::calcImageCrc() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
if (update.fullFileSize == 0) {
return HasReturnvaluesIF::RETURN_FAILED;
}
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
result = FilesystemHelper::checkPath(update.file); result = FilesystemHelper::checkPath(update.file);
#endif
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::calcImageCrc: File " << update.file << " does not exist" sif::warning << "PlocSupvHelper::calcImageCrc: File " << update.file << " does not exist"
<< std::endl; << std::endl;
return result; return result;
} }
#endif
auto crc16Calcer = etl::crc16_ccitt();
std::ifstream file(update.file, std::ifstream::binary); std::ifstream file(update.file, std::ifstream::binary);
uint16_t remainder = CRC16_INIT; std::array<uint8_t, 1025> crcBuf{};
uint8_t input;
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
ProgressPrinter progress("Supervisor update crc calculation", update.length, ProgressPrinter progress("Supervisor update crc calculation", update.fullFileSize,
ProgressPrinter::ONE_PERCENT); ProgressPrinter::ONE_PERCENT);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint32_t byteCount = 0; uint32_t byteCount = 0;
for (byteCount = 0; byteCount < update.length; byteCount++) { size_t bytesToRead = 1024;
while (byteCount < update.fullFileSize) {
size_t remLen = update.fullFileSize - byteCount;
if (remLen < 1024) {
bytesToRead = remLen;
} else {
bytesToRead = 1024;
}
file.seekg(byteCount, file.beg); file.seekg(byteCount, file.beg);
file.read(reinterpret_cast<char*>(&input), 1); file.read(reinterpret_cast<char*>(crcBuf.data()), bytesToRead);
remainder = CRC::crc16ccitt(&input, sizeof(input), remainder); crc16Calcer.add(crcBuf.begin(), crcBuf.begin() + bytesToRead);
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
progress.print(byteCount); progress.print(byteCount);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
byteCount += bytesToRead;
} }
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
progress.print(byteCount); progress.print(byteCount);
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
file.close(); update.crc = crc16Calcer.value();
update.crc = remainder;
return result; return result;
} }
ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() { ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
resetSpParams(); resetSpParams();
// Will hold status report for later processing
std::array<uint8_t, 32> statusReportBuf{};
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
// Verification of update write procedure // Verification of update write procedure
supv::CheckMemory packet(spParams); supv::CheckMemory packet(spParams);
result = packet.buildPacket(update.memoryId, update.startAddress, update.length); result = packet.buildPacket(update.memoryId, update.startAddress, update.fullFileSize);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -545,34 +685,55 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
result = handleTmReception(static_cast<size_t>(updateStatusReport.getNominalSize()), bool exeAlreadyHandled = false;
supv::recv_timeout::UPDATE_STATUS_REPORT); uint32_t timeout = std::max(CRC_EXECUTION_TIMEOUT, supv::recv_timeout::UPDATE_STATUS_REPORT);
result = updateStatusReport.checkCrc(); result = handleTmReception(ccsds::HEADER_LEN, tmBuf.data(), timeout);
if (result != RETURN_OK) { ploc::SpTmReader spReader(tmBuf.data(), tmBuf.size());
sif::warning << "PlocSupvHelper::handleTmReception: CRC check failed" << std::endl; if (spReader.getApid() == supv::APID_EXE_FAILURE) {
return result; exeAlreadyHandled = true;
result = handleRemainingExeReport(spReader);
} else if (spReader.getApid() == supv::APID_UPDATE_STATUS_REPORT) {
size_t remBytes = spReader.getPacketDataLen() + 1;
result = handleTmReception(remBytes, tmBuf.data() + ccsds::HEADER_LEN,
supv::recv_timeout::UPDATE_STATUS_REPORT);
if (result != RETURN_OK) {
sif::warning
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
<< std::endl;
return result;
}
result = updateStatusReport.checkCrc();
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC check failed" << std::endl;
return result;
}
// Copy into other buffer because data will be overwritten when reading execution report
std::memcpy(statusReportBuf.data(), tmBuf.data(), updateStatusReport.getNominalSize());
} }
if (result != RETURN_OK) {
sif::warning if (not exeAlreadyHandled) {
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report" result = handleExe(CRC_EXECUTION_TIMEOUT);
<< std::endl; if (result != RETURN_OK) {
return result; return result;
} }
result = handleExe(CRC_EXECUTION_TIMEOUT);
if (result != RETURN_OK) {
return result;
} }
// Now process the status report
updateStatusReport.setData(statusReportBuf.data(), statusReportBuf.size());
result = updateStatusReport.parseDataField(); result = updateStatusReport.parseDataField();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = updateStatusReport.verifycrc(update.crc); if (update.crcShouldBeChecked) {
if (result != RETURN_OK) { result = updateStatusReport.verifycrc(update.crc);
sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC failure. Expected CRC 0x" if (result != RETURN_OK) {
<< std::hex << update.crc << " but received CRC 0x" << updateStatusReport.getCrc() sif::warning << "PlocSupvHelper::handleCheckMemoryCommand: CRC failure. Expected CRC 0x"
<< std::endl; << std::setfill('0') << std::hex << std::setw(4)
return result; << static_cast<uint16_t>(update.crc) << " but received CRC 0x" << std::setw(4)
<< updateStatusReport.getCrc() << std::dec << std::endl;
return result;
}
} }
return result; return result;
} }
@ -585,14 +746,14 @@ uint32_t PlocSupvHelper::getFileSize(std::string filename) {
return size; return size;
} }
ReturnValue_t PlocSupvHelper::handleEventBufferReception() { ReturnValue_t PlocSupvHelper::handleEventBufferReception(ploc::SpTmReader& reader) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
std::string filename = Filenaming::generateAbsoluteFilename( std::string filename = Filenaming::generateAbsoluteFilename(
eventBufferReq.path, eventBufferReq.filename, timestamping); eventBufferReq.path, eventBufferReq.filename, timestamping);
std::ofstream file(filename, std::ios_base::app | std::ios_base::out); std::ofstream file(filename, std::ios_base::app | std::ios_base::out);
uint32_t packetsRead = 0; uint32_t packetsRead = 0;
size_t requestLen = 0; size_t requestLen = 0;
ploc::SpTmReader tmReader(tmBuf.data(), tmBuf.size()); bool firstPacket = true;
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) { for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) {
if (terminate) { if (terminate) {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1); triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1);
@ -604,6 +765,10 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
} else { } else {
requestLen = SIZE_EVENT_BUFFER_FULL_PACKET; requestLen = SIZE_EVENT_BUFFER_FULL_PACKET;
} }
if (firstPacket) {
firstPacket = false;
requestLen -= 6;
}
result = handleTmReception(requestLen); result = handleTmReception(requestLen);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet" sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet"
@ -611,20 +776,20 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
file.close(); file.close();
return result; return result;
} }
ReturnValue_t result = tmReader.checkCrc(); ReturnValue_t result = reader.checkCrc();
if (result != RETURN_OK) { if (result != RETURN_OK) {
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid); triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
return result; return result;
} }
uint16_t apid = tmReader.getApid(); uint16_t apid = reader.getApid();
if (apid != supv::APID_MRAM_DUMP_TM) { if (apid != supv::APID_MRAM_DUMP_TM) {
sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet " sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet "
<< "with APID 0x" << std::hex << apid << std::endl; << "with APID 0x" << std::hex << apid << std::endl;
file.close(); file.close();
return EVENT_BUFFER_REPLY_INVALID_APID; return EVENT_BUFFER_REPLY_INVALID_APID;
} }
file.write(reinterpret_cast<const char*>(tmReader.getPacketData()), file.write(reinterpret_cast<const char*>(reader.getPacketData()),
tmReader.getPayloadDataLength()); reader.getPayloadDataLength());
} }
return result; return result;
} }

View File

@ -42,52 +42,61 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
//! [EXPORT] : [COMMENT] Terminated event buffer request by command //! [EXPORT] : [COMMENT] Terminated event buffer request by command
//! P1: Number of packets read before process was terminated //! P1: Number of packets read before process was terminated
static const Event SUPV_EVENT_BUFFER_REQUEST_TERMINATED = MAKE_EVENT(7, severity::LOW); static const Event SUPV_EVENT_BUFFER_REQUEST_TERMINATED = MAKE_EVENT(7, severity::LOW);
//! Status of memory check command
//! P1: Returncode, 0 for success, other value with returncode for failure
static constexpr Event SUPV_MEM_CHECK_OK = MAKE_EVENT(8, severity::INFO);
static constexpr Event SUPV_MEM_CHECK_FAIL = MAKE_EVENT(9, severity::INFO);
//! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command //! [EXPORT] : [COMMENT] Communication interface returned failure when trying to send the command
//! to the supervisor //! to the supervisor
//! P1: Return value returned by the communication interface sendMessage function //! P1: Return value returned by the communication interface sendMessage function
//! P2: Internal state of supervisor helper //! P2: Internal state of supervisor helper
static const Event SUPV_SENDING_COMMAND_FAILED = MAKE_EVENT(8, severity::LOW); static const Event SUPV_SENDING_COMMAND_FAILED = MAKE_EVENT(16, severity::LOW);
//! [EXPORT] : [COMMENT] Request receive message of communication interface failed //! [EXPORT] : [COMMENT] Request receive message of communication interface failed
//! P1: Return value returned by the communication interface requestReceiveMessage function //! P1: Return value returned by the communication interface requestReceiveMessage function
//! P2: Internal state of supervisor helper //! P2: Internal state of supervisor helper
static const Event SUPV_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(9, severity::LOW); static const Event SUPV_HELPER_REQUESTING_REPLY_FAILED = MAKE_EVENT(17, severity::LOW);
//! [EXPORT] : [COMMENT] Reading receive message of communication interface failed //! [EXPORT] : [COMMENT] Reading receive message of communication interface failed
//! P1: Return value returned by the communication interface readingReceivedMessage function //! P1: Return value returned by the communication interface readingReceivedMessage function
//! P2: Internal state of supervisor helper //! P2: Internal state of supervisor helper
static const Event SUPV_HELPER_READING_REPLY_FAILED = MAKE_EVENT(10, severity::LOW); static const Event SUPV_HELPER_READING_REPLY_FAILED = MAKE_EVENT(18, severity::LOW);
//! [EXPORT] : [COMMENT] Did not receive acknowledgement report //! [EXPORT] : [COMMENT] Did not receive acknowledgement report
//! P1: Number of bytes missing //! P1: Number of bytes missing
//! P2: Internal state of MPSoC helper //! P2: Internal state of MPSoC helper
static const Event SUPV_MISSING_ACK = MAKE_EVENT(11, severity::LOW); static const Event SUPV_MISSING_ACK = MAKE_EVENT(19, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor did not receive execution report //! [EXPORT] : [COMMENT] Supervisor did not receive execution report
//! P1: Number of bytes missing //! P1: Number of bytes missing
//! P2: Internal state of supervisor helper //! P2: Internal state of supervisor helper
static const Event SUPV_MISSING_EXE = MAKE_EVENT(12, severity::LOW); static const Event SUPV_MISSING_EXE = MAKE_EVENT(20, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor received acknowledgment failure report //! [EXPORT] : [COMMENT] Supervisor received acknowledgment failure report
//! P1: Internal state of supervisor helper //! P1: Internal state of supervisor helper
static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(13, severity::LOW); static const Event SUPV_ACK_FAILURE_REPORT = MAKE_EVENT(21, severity::LOW);
//! [EXPORT] : [COMMENT] Execution report failure //! [EXPORT] : [COMMENT] Execution report failure
//! P1: //! P1:
static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(14, severity::LOW); static const Event SUPV_EXE_FAILURE_REPORT = MAKE_EVENT(22, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor expected acknowledgment report but received space packet with //! [EXPORT] : [COMMENT] Supervisor expected acknowledgment report but received space packet with
//! other apid P1: Apid of received space packet P2: Internal state of supervisor helper //! other apid P1: Apid of received space packet P2: Internal state of supervisor helper
static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(15, severity::LOW); static const Event SUPV_ACK_INVALID_APID = MAKE_EVENT(23, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor helper expected execution report but received space packet //! [EXPORT] : [COMMENT] Supervisor helper expected execution report but received space packet
//! with other apid P1: Apid of received space packet P2: Internal state of supervisor helper //! with other apid P1: Apid of received space packet P2: Internal state of supervisor helper
static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(16, severity::LOW); static const Event SUPV_EXE_INVALID_APID = MAKE_EVENT(24, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to receive acknowledgment report //! [EXPORT] : [COMMENT] Failed to receive acknowledgment report
//! P1: Return value //! P1: Return value
//! P2: Apid of command for which the reception of the acknowledgment report failed //! P2: Apid of command for which the reception of the acknowledgment report failed
static const Event ACK_RECEPTION_FAILURE = MAKE_EVENT(17, severity::LOW); static const Event ACK_RECEPTION_FAILURE = MAKE_EVENT(25, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to receive execution report //! [EXPORT] : [COMMENT] Failed to receive execution report
//! P1: Return value //! P1: Return value
//! P2: Apid of command for which the reception of the execution report failed //! P2: Apid of command for which the reception of the execution report failed
static const Event EXE_RECEPTION_FAILURE = MAKE_EVENT(18, severity::LOW); static const Event EXE_RECEPTION_FAILURE = MAKE_EVENT(26, severity::LOW);
//! [EXPORT] : [COMMENT] Update procedure failed when sending packet with number P1 //! [EXPORT] : [COMMENT] Update procedure failed when sending packet.
//! P1: Packet number for which the memory write command fails //! P1: First byte percent, third and fourth byte Sequence Count, P2: Bytes written
static const Event WRITE_MEMORY_FAILED = MAKE_EVENT(19, severity::LOW); static const Event WRITE_MEMORY_FAILED = MAKE_EVENT(27, severity::LOW);
static const Event SUPV_REPLY_SIZE_MISSMATCH = MAKE_EVENT(20, severity::LOW); static const Event SUPV_REPLY_SIZE_MISSMATCH = MAKE_EVENT(28, severity::LOW);
static const Event SUPV_REPLY_CRC_MISSMATCH = MAKE_EVENT(21, severity::LOW); static const Event SUPV_REPLY_CRC_MISSMATCH = MAKE_EVENT(29, severity::LOW);
//! [EXPORT] : [COMMENT] Will be triggered every 5 percent of the update progress.
//! P1: First byte percent, third and fourth byte Sequence Count, P2: Bytes written
static constexpr Event SUPV_UPDATE_PROGRESS = MAKE_EVENT(30, severity::INFO);
PlocSupvHelper(object_id_t objectId); PlocSupvHelper(object_id_t objectId);
virtual ~PlocSupvHelper(); virtual ~PlocSupvHelper();
@ -107,8 +116,13 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
* *
* @return RETURN_OK if successful, otherwise error return value * @return RETURN_OK if successful, otherwise error return value
*/ */
ReturnValue_t performUpdate(const supv::UpdateParams& params);
ReturnValue_t startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress); ReturnValue_t startUpdate(std::string file, uint8_t memoryId, uint32_t startAddress);
ReturnValue_t performMemCheck(uint8_t memoryId, uint32_t startAddress, size_t sizeToCheck,
bool checkCrc);
ReturnValue_t performMemCheck(std::string file, uint8_t memoryId, uint32_t startAddress);
/** /**
* @brief This initiate the continuation of a failed update. * @brief This initiate the continuation of a failed update.
*/ */
@ -124,6 +138,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
*/ */
void stopProcess(); void stopProcess();
static uint32_t buildProgParams1(uint8_t percent, uint16_t seqCount);
private: private:
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPV_HELPER; static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPV_HELPER;
@ -150,13 +166,17 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
uint32_t startAddress; uint32_t startAddress;
// Absolute name of file containing update data // Absolute name of file containing update data
std::string file; std::string file;
// Length of full file
size_t fullFileSize;
// Size of update // Size of update
uint32_t length; uint32_t length;
uint32_t crc; uint32_t crc;
size_t remainingSize; bool crcShouldBeChecked = true;
size_t bytesWritten; size_t bytesWritten;
uint32_t packetNum; uint32_t packetNum;
uint16_t sequenceCount; uint16_t sequenceCount;
uint8_t progressPercent;
bool deleteMemory = false;
}; };
struct Update update; struct Update update;
@ -170,7 +190,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
EventBufferRequest eventBufferReq; EventBufferRequest eventBufferReq;
enum class InternalState { IDLE, UPDATE, CONTINUE_UPDATE, REQUEST_EVENT_BUFFER }; enum class InternalState { IDLE, UPDATE, CONTINUE_UPDATE, REQUEST_EVENT_BUFFER, CHECK_MEMORY };
InternalState internalState = InternalState::IDLE; InternalState internalState = InternalState::IDLE;
@ -198,8 +218,11 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
// Remembers APID to know at which command a procedure failed // Remembers APID to know at which command a procedure failed
uint16_t rememberApid = 0; uint16_t rememberApid = 0;
ReturnValue_t performUpdate(); void executeFullCheckMemoryCommand();
ReturnValue_t executeUpdate();
ReturnValue_t continueUpdate(); ReturnValue_t continueUpdate();
ReturnValue_t updateOperation();
ReturnValue_t writeUpdatePackets(); ReturnValue_t writeUpdatePackets();
ReturnValue_t performEventBufferRequest(); ReturnValue_t performEventBufferRequest();
ReturnValue_t handlePacketTransmission(ploc::SpTcBase& packet, ReturnValue_t handlePacketTransmission(ploc::SpTcBase& packet,
@ -225,7 +248,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
* @note It can take up to 70 seconds until the supervisor replies with an acknowledgment * @note It can take up to 70 seconds until the supervisor replies with an acknowledgment
* failure report. * failure report.
*/ */
ReturnValue_t handleTmReception(size_t remainingBytes, uint32_t timeout = 70000); ReturnValue_t handleTmReception(size_t remainingBytes, uint8_t* readBuf = nullptr,
uint32_t timeout = 70000);
ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader); ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader);
ReturnValue_t selectMemory(); ReturnValue_t selectMemory();
@ -235,6 +259,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
// finished. // finished.
ReturnValue_t calcImageCrc(); ReturnValue_t calcImageCrc();
ReturnValue_t handleCheckMemoryCommand(); ReturnValue_t handleCheckMemoryCommand();
ReturnValue_t exeReportHandling();
/** /**
* @brief Return size of file with name filename * @brief Return size of file with name filename
* *
@ -243,7 +268,8 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
* @return The size of the file * @return The size of the file
*/ */
uint32_t getFileSize(std::string filename); uint32_t getFileSize(std::string filename);
ReturnValue_t handleEventBufferReception(); ReturnValue_t handleEventBufferReception(ploc::SpTmReader& reader);
ReturnValue_t handleRemainingExeReport(ploc::SpTmReader& reader);
void resetSpParams(); void resetSpParams();
}; };

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 213 translations. * @brief Auto-generated event translation file. Contains 216 translations.
* @details * @details
* Generated on: 2022-08-18 11:23:13 * Generated on: 2022-08-24 16:44:18
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -196,6 +196,8 @@ const char *TERMINATED_UPDATE_PROCEDURE_STRING = "TERMINATED_UPDATE_PROCEDURE";
const char *SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL_STRING = "SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL"; const char *SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL_STRING = "SUPV_EVENT_BUFFER_REQUEST_SUCCESSFUL";
const char *SUPV_EVENT_BUFFER_REQUEST_FAILED_STRING = "SUPV_EVENT_BUFFER_REQUEST_FAILED"; const char *SUPV_EVENT_BUFFER_REQUEST_FAILED_STRING = "SUPV_EVENT_BUFFER_REQUEST_FAILED";
const char *SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING = "SUPV_EVENT_BUFFER_REQUEST_TERMINATED"; const char *SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING = "SUPV_EVENT_BUFFER_REQUEST_TERMINATED";
const char *SUPV_MEM_CHECK_OK_STRING = "SUPV_MEM_CHECK_OK";
const char *SUPV_MEM_CHECK_FAIL_STRING = "SUPV_MEM_CHECK_FAIL";
const char *SUPV_SENDING_COMMAND_FAILED_STRING = "SUPV_SENDING_COMMAND_FAILED"; const char *SUPV_SENDING_COMMAND_FAILED_STRING = "SUPV_SENDING_COMMAND_FAILED";
const char *SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING = "SUPV_HELPER_REQUESTING_REPLY_FAILED"; const char *SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING = "SUPV_HELPER_REQUESTING_REPLY_FAILED";
const char *SUPV_HELPER_READING_REPLY_FAILED_STRING = "SUPV_HELPER_READING_REPLY_FAILED"; const char *SUPV_HELPER_READING_REPLY_FAILED_STRING = "SUPV_HELPER_READING_REPLY_FAILED";
@ -210,6 +212,7 @@ const char *EXE_RECEPTION_FAILURE_STRING = "EXE_RECEPTION_FAILURE";
const char *WRITE_MEMORY_FAILED_STRING = "WRITE_MEMORY_FAILED"; const char *WRITE_MEMORY_FAILED_STRING = "WRITE_MEMORY_FAILED";
const char *SUPV_REPLY_SIZE_MISSMATCH_STRING = "SUPV_REPLY_SIZE_MISSMATCH"; const char *SUPV_REPLY_SIZE_MISSMATCH_STRING = "SUPV_REPLY_SIZE_MISSMATCH";
const char *SUPV_REPLY_CRC_MISSMATCH_STRING = "SUPV_REPLY_CRC_MISSMATCH"; const char *SUPV_REPLY_CRC_MISSMATCH_STRING = "SUPV_REPLY_CRC_MISSMATCH";
const char *SUPV_UPDATE_PROGRESS_STRING = "SUPV_UPDATE_PROGRESS";
const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE"; const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE";
const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_SW_STRING = "REBOOT_SW";
const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED";
@ -600,33 +603,39 @@ const char *translateEvents(Event event) {
case (13607): case (13607):
return SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING; return SUPV_EVENT_BUFFER_REQUEST_TERMINATED_STRING;
case (13608): case (13608):
return SUPV_SENDING_COMMAND_FAILED_STRING; return SUPV_MEM_CHECK_OK_STRING;
case (13609): case (13609):
return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING; return SUPV_MEM_CHECK_FAIL_STRING;
case (13610):
return SUPV_HELPER_READING_REPLY_FAILED_STRING;
case (13611):
return SUPV_MISSING_ACK_STRING;
case (13612):
return SUPV_MISSING_EXE_STRING;
case (13613):
return SUPV_ACK_FAILURE_REPORT_STRING;
case (13614):
return SUPV_EXE_FAILURE_REPORT_STRING;
case (13615):
return SUPV_ACK_INVALID_APID_STRING;
case (13616): case (13616):
return SUPV_EXE_INVALID_APID_STRING; return SUPV_SENDING_COMMAND_FAILED_STRING;
case (13617): case (13617):
return ACK_RECEPTION_FAILURE_STRING; return SUPV_HELPER_REQUESTING_REPLY_FAILED_STRING;
case (13618): case (13618):
return EXE_RECEPTION_FAILURE_STRING; return SUPV_HELPER_READING_REPLY_FAILED_STRING;
case (13619): case (13619):
return WRITE_MEMORY_FAILED_STRING; return SUPV_MISSING_ACK_STRING;
case (13620): case (13620):
return SUPV_REPLY_SIZE_MISSMATCH_STRING; return SUPV_MISSING_EXE_STRING;
case (13621): case (13621):
return SUPV_ACK_FAILURE_REPORT_STRING;
case (13622):
return SUPV_EXE_FAILURE_REPORT_STRING;
case (13623):
return SUPV_ACK_INVALID_APID_STRING;
case (13624):
return SUPV_EXE_INVALID_APID_STRING;
case (13625):
return ACK_RECEPTION_FAILURE_STRING;
case (13626):
return EXE_RECEPTION_FAILURE_STRING;
case (13627):
return WRITE_MEMORY_FAILED_STRING;
case (13628):
return SUPV_REPLY_SIZE_MISSMATCH_STRING;
case (13629):
return SUPV_REPLY_CRC_MISSMATCH_STRING; return SUPV_REPLY_CRC_MISSMATCH_STRING;
case (13630):
return SUPV_UPDATE_PROGRESS_STRING;
case (13700): case (13700):
return ALLOC_FAILURE_STRING; return ALLOC_FAILURE_STRING;
case (13701): case (13701):

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 133 translations. * Contains 133 translations.
* Generated on: 2022-08-18 11:23:13 * Generated on: 2022-08-24 16:44:18
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -8,6 +8,7 @@
#include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h" #include "fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h"
#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" #include "fsfw_hal/devicehandlers/MgmRM3100Handler.h"
#include "mission/devices/devicedefinitions/IMTQHandlerDefinitions.h" #include "mission/devices/devicedefinitions/IMTQHandlerDefinitions.h"
#include "mission/devices/devicedefinitions/SusDefinitions.h"
class AcsController : public ExtendedControllerBase { class AcsController : public ExtendedControllerBase {
public: public:
@ -53,9 +54,24 @@ class AcsController : public ExtendedControllerBase {
void copyMgmData(); void copyMgmData();
// Sun Sensors
std::array<SUS::SusDataset, 12> susSets{
SUS::SusDataset(objects::SUS_0_N_LOC_XFYFZM_PT_XF),
SUS::SusDataset(objects::SUS_1_N_LOC_XBYFZM_PT_XB),
SUS::SusDataset(objects::SUS_2_N_LOC_XFYBZB_PT_YB),
SUS::SusDataset(objects::SUS_3_N_LOC_XFYBZF_PT_YF),
SUS::SusDataset(objects::SUS_4_N_LOC_XMYFZF_PT_ZF),
SUS::SusDataset(objects::SUS_5_N_LOC_XFYMZB_PT_ZB),
SUS::SusDataset(objects::SUS_6_R_LOC_XFYBZM_PT_XF),
SUS::SusDataset(objects::SUS_7_R_LOC_XBYBZM_PT_XB),
SUS::SusDataset(objects::SUS_8_R_LOC_XBYBZB_PT_YB),
SUS::SusDataset(objects::SUS_9_R_LOC_XBYBZB_PT_YF),
SUS::SusDataset(objects::SUS_10_N_LOC_XMYBZF_PT_ZF),
SUS::SusDataset(objects::SUS_11_R_LOC_XBYMZB_PT_ZB),
};
// Initial delay to make sure all pool variables have been initialized their owners // Initial delay to make sure all pool variables have been initialized their owners
Countdown initialCountdown = Countdown(INIT_DELAY); Countdown initialCountdown = Countdown(INIT_DELAY);
// Sun Sensors
}; };
#endif /* MISSION_CONTROLLER_ACSCONTROLLER_H_ */ #endif /* MISSION_CONTROLLER_ACSCONTROLLER_H_ */

View File

@ -8,7 +8,7 @@
namespace acsctrl { namespace acsctrl {
enum SetIds : uint32_t { MGM_SENSOR_DATA }; enum SetIds : uint32_t { MGM_SENSOR_DATA, SUS_SENSOR_DATA };
enum PoolIds : lp_id_t { enum PoolIds : lp_id_t {
MGM_0_LIS3_UT, MGM_0_LIS3_UT,
@ -16,10 +16,29 @@ enum PoolIds : lp_id_t {
MGM_2_LIS3_UT, MGM_2_LIS3_UT,
MGM_3_RM3100_UT, MGM_3_RM3100_UT,
MGM_IMTQ_CAL_NT, MGM_IMTQ_CAL_NT,
MGM_IMTQ_CAL_ACT_STATUS MGM_IMTQ_CAL_ACT_STATUS,
SUS_0_N_LOC_XFYFZM_PT_XF,
SUS_6_R_LOC_XFYBZM_PT_XF,
SUS_1_N_LOC_XBYFZM_PT_XB,
SUS_7_R_LOC_XBYBZM_PT_XB,
SUS_2_N_LOC_XFYBZB_PT_YB,
SUS_8_R_LOC_XBYBZB_PT_YB,
SUS_3_N_LOC_XFYBZF_PT_YF,
SUS_9_R_LOC_XBYBZB_PT_YF,
SUS_4_N_LOC_XMYFZF_PT_ZF,
SUS_10_N_LOC_XMYBZF_PT_ZF,
SUS_5_N_LOC_XFYMZB_PT_ZB,
SUS_11_R_LOC_XBYMZB_PT_ZB,
}; };
static constexpr uint8_t MGM_SET_ENTRIES = 10; static constexpr uint8_t MGM_SET_ENTRIES = 10;
static constexpr uint8_t SUS_SET_ENTRIES = 12;
/** /**
* @brief This dataset can be used to store the collected temperatures of all temperature sensors * @brief This dataset can be used to store the collected temperatures of all temperature sensors
@ -41,6 +60,13 @@ class MgmData : public StaticLocalDataSet<MGM_SET_ENTRIES> {
private: private:
}; };
class SusData : public StaticLocalDataSet<SUS_SET_ENTRIES> {
public:
SusData(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, SUS_SENSOR_DATA) {}
private:
};
} // namespace acsctrl } // namespace acsctrl
#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_ACSCTRLDEFINITIONS_H_ */ #endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_ACSCTRLDEFINITIONS_H_ */

View File

@ -107,10 +107,7 @@ class SpTmReader : public SpacePacketReader {
uint16_t getPayloadDataLength() { return getPacketDataLen() - 2; } uint16_t getPayloadDataLength() { return getPacketDataLen() - 2; }
ReturnValue_t checkCrc() { ReturnValue_t checkCrc() {
const uint8_t* crcPtr = getFullData() + getFullPacketLen() - CRC_SIZE; if (CRC::crc16ccitt(getFullData(), getFullPacketLen()) != 0) {
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(getFullData(), getFullPacketLen() - CRC_SIZE);
if (recalculatedCrc != receivedCrc) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;

View File

@ -4,7 +4,7 @@
# custom cross-compiler and sysroot path setups # custom cross-compiler and sysroot path setups
# Adapt the following two entries to your need # Adapt the following two entries to your need
CROSS_COMPILE_BIN_PATH="$HOME/EIVE/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" CROSS_COMPILE_BIN_PATH="/opt/q7s-gcc/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin"
export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-linux-gnueabi" export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-linux-gnueabi"
export PATH=$PATH:${CROSS_COMPILE_BIN_PATH} export PATH=$PATH:${CROSS_COMPILE_BIN_PATH}

View File

@ -4,7 +4,7 @@
# custom cross-compiler and sysroot path setups # custom cross-compiler and sysroot path setups
# Adapt the following two entries to your need # Adapt the following two entries to your need
CROSS_COMPILE_BIN_PATH="$HOME/EIVE/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin" CROSS_COMPILE_BIN_PATH="/opt/q7s-gcc/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin"
export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-linux-gnueabi" export ZYNQ_7020_SYSROOT="/opt/xiphos/sdk/ark/sysroots/cortexa9hf-neon-xiphos-linux-gnueabi"
export PATH=$PATH:${CROSS_COMPILE_BIN_PATH} export PATH=$PATH:${CROSS_COMPILE_BIN_PATH}

2
tmtc

@ -1 +1 @@
Subproject commit 1b39bb2ad2421db89487b4ea352edbd4d420b9b1 Subproject commit d19cdfa5663966548918091005c7e9bc912e4041