eive-obsw/linux/payload/plocSupvDefs.h

2089 lines
71 KiB
C
Raw Normal View History

#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_
2022-01-17 15:58:27 +01:00
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/globalfunctions/CRC.h>
#include <fsfw/serialize/SerializeAdapter.h>
#include <fsfw/timemanager/Clock.h>
#include <fsfw/tmtcpacket/ccsds/SpacePacketCreator.h>
#include <fsfw/tmtcpacket/ccsds/SpacePacketReader.h>
2023-03-26 16:42:00 +02:00
#include <mission/payload/plocSpBase.h>
2022-04-11 16:52:50 +02:00
#include <atomic>
2023-11-15 15:41:51 +01:00
#include "eive/eventSubsystemIds.h"
#include "eive/resultClassIds.h"
2022-03-30 09:19:30 +02:00
namespace supv {
2023-11-28 15:37:25 +01:00
static constexpr bool DEBUG_PLOC_SUPV = false;
2023-11-14 18:20:52 +01:00
static constexpr bool REDUCE_NORMAL_MODE_PRINTOUT = true;
2023-11-13 15:33:11 +01:00
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
//! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet
static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Unhandled event. P1: APID, P2: Service ID
static constexpr Event SUPV_UNKNOWN_TM = MAKE_EVENT(2, severity::LOW);
static constexpr Event SUPV_UNINIMPLEMENTED_TM = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report
static const Event SUPV_ACK_FAILURE = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC received execution failure report
//! P1: ID of command for which the execution failed
//! P2: Status code sent by the supervisor handler
static const Event SUPV_EXE_FAILURE = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc
static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(6, severity::LOW);
//! [EXPORT] : [COMMENT] Supervisor helper currently executing a command
static const Event SUPV_HELPER_EXECUTING = MAKE_EVENT(7, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to build the command to shutdown the MPSoC
static const Event SUPV_MPSOC_SHUTDOWN_BUILD_FAILED = MAKE_EVENT(8, severity::LOW);
2023-11-13 16:32:40 +01:00
//! [EXPORT] : [COMMENT] Received ACK, but no related command is unknown or has not been sent
// by this software instance. P1: Module APID. P2: Service ID.
static const Event SUPV_ACK_UNKNOWN_COMMAND = MAKE_EVENT(9, severity::LOW);
//! [EXPORT] : [COMMENT] Received ACK EXE, but no related command is unknown or has not been sent
// by this software instance. P1: Module APID. P2: Service ID.
static const Event SUPV_EXE_ACK_UNKNOWN_COMMAND = MAKE_EVENT(10, severity::LOW);
2023-11-13 15:33:11 +01:00
extern std::atomic_bool SUPV_ON;
2023-11-15 14:17:43 +01:00
static constexpr uint32_t INTER_COMMAND_DELAY = 20;
2023-11-09 17:19:28 +01:00
static constexpr uint32_t BOOT_TIMEOUT_MS = 4000;
2023-11-14 15:28:27 +01:00
static constexpr uint32_t MAX_TRANSITION_TIME_TO_ON_MS = BOOT_TIMEOUT_MS + 2000;
2023-11-09 17:19:28 +01:00
static constexpr uint32_t MAX_TRANSITION_TIME_TO_OFF_MS = 1000;
namespace result {
static const uint8_t INTERFACE_ID = CLASS_ID::SUPV_RETURN_VALUES_IF;
//! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
2022-11-08 17:07:12 +01:00
static constexpr ReturnValue_t INVALID_SERVICE_ID = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor
2022-11-08 17:07:12 +01:00
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor
2022-11-08 17:07:12 +01:00
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA4);
//! [EXPORT] : [COMMENT] Failed to read current system time
2022-11-08 17:07:12 +01:00
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0
//! for PS, 1 for PL and 2 for INT
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid
//! timeouts must be in the range between 1000 and 360000 ms.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA8);
//! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be
//! larger than 21.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA9);
//! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1
//! and 2.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA);
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAB);
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe
//! commands are invalid (e.g. start address bigger than stop address)
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAC);
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with
//! other apid.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD);
//! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist
2022-11-08 17:07:12 +01:00
static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAE);
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have
//! been created with the reception of the first dump packet.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAF);
static constexpr ReturnValue_t INVALID_REPLY_LENGTH = MAKE_RETURN_CODE(0xB0);
//! [EXPORT] : [COMMENT] Received action command has invalid length
2022-11-08 17:07:12 +01:00
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB1);
//! [EXPORT] : [COMMENT] Filename too long
2022-11-08 17:07:12 +01:00
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xB2);
//! [EXPORT] : [COMMENT] Received update status report with invalid packet length field
2022-11-08 17:07:12 +01:00
static const ReturnValue_t UPDATE_STATUS_REPORT_INVALID_LENGTH = MAKE_RETURN_CODE(0xB3);
//! [EXPORT] : [COMMENT] Update status report does not contain expected CRC. There might be a bit
//! flip in the update memory region.
2022-11-08 17:07:12 +01:00
static const ReturnValue_t UPDATE_CRC_FAILURE = MAKE_RETURN_CODE(0xB4);
//! [EXPORT] : [COMMENT] Supervisor helper task ist currently executing a command (wait until
//! helper tas has finished or interrupt by sending the terminate command)
2022-11-08 17:07:12 +01:00
static const ReturnValue_t SUPV_HELPER_EXECUTING = MAKE_RETURN_CODE(0xB5);
static constexpr ReturnValue_t BUF_TOO_SMALL = MAKE_RETURN_CODE(0xC0);
2022-11-08 16:26:30 +01:00
static constexpr ReturnValue_t NO_REPLY_TIMEOUT = MAKE_RETURN_CODE(0xC1);
}; // namespace result
2022-11-07 09:26:36 +01:00
2022-11-07 13:37:51 +01:00
static constexpr uint16_t DEFAULT_SEQ_COUNT = 0;
/** Command IDs */
static const DeviceCommandId_t NONE = 0;
static const DeviceCommandId_t GET_HK_REPORT = 1;
static const DeviceCommandId_t START_MPSOC = 3;
static const DeviceCommandId_t SHUTDOWN_MPSOC = 4;
static const DeviceCommandId_t SEL_MPSOC_BOOT_IMAGE = 5;
static const DeviceCommandId_t SET_BOOT_TIMEOUT = 6;
static const DeviceCommandId_t SET_MAX_RESTART_TRIES = 7;
static const DeviceCommandId_t RESET_MPSOC = 8;
static const DeviceCommandId_t SET_TIME_REF = 9;
2021-07-22 08:06:04 +02:00
static const DeviceCommandId_t DISABLE_PERIOIC_HK_TRANSMISSION = 10;
2021-07-24 13:57:05 +02:00
static const DeviceCommandId_t GET_BOOT_STATUS_REPORT = 11;
static const DeviceCommandId_t ENABLE_LATCHUP_ALERT = 15;
static const DeviceCommandId_t DISABLE_LATCHUP_ALERT = 16;
static const DeviceCommandId_t SET_ALERT_LIMIT = 18;
static const DeviceCommandId_t SET_ADC_ENABLED_CHANNELS = 21;
static const DeviceCommandId_t SET_ADC_WINDOW_AND_STRIDE = 22;
static const DeviceCommandId_t SET_ADC_THRESHOLD = 23;
static const DeviceCommandId_t GET_LATCHUP_STATUS_REPORT = 24;
static const DeviceCommandId_t COPY_ADC_DATA_TO_MRAM = 25;
static const DeviceCommandId_t RUN_AUTO_EM_TESTS = 28;
static const DeviceCommandId_t WIPE_MRAM = 29;
2021-08-29 07:31:34 +02:00
static const DeviceCommandId_t FIRST_MRAM_DUMP = 30;
static const DeviceCommandId_t SET_GPIO = 34;
static const DeviceCommandId_t READ_GPIO = 35;
static const DeviceCommandId_t RESTART_SUPERVISOR = 36;
2023-11-08 10:46:59 +01:00
static const DeviceCommandId_t REQUEST_LOGGING_COUNTERS = 38;
2022-11-08 20:37:57 +01:00
static constexpr DeviceCommandId_t FACTORY_RESET = 39;
2021-08-31 11:20:21 +02:00
static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43;
2022-04-06 07:10:20 +02:00
static const DeviceCommandId_t START_MPSOC_QUIET = 45;
static const DeviceCommandId_t SET_SHUTDOWN_TIMEOUT = 46;
static const DeviceCommandId_t FACTORY_FLASH = 47;
2022-04-10 18:46:39 +02:00
static const DeviceCommandId_t PERFORM_UPDATE = 48;
static const DeviceCommandId_t TERMINATE_SUPV_HELPER = 49;
2022-04-11 16:52:50 +02:00
static const DeviceCommandId_t ENABLE_AUTO_TM = 50;
static const DeviceCommandId_t DISABLE_AUTO_TM = 51;
2022-04-13 11:56:37 +02:00
static const DeviceCommandId_t LOGGING_REQUEST_EVENT_BUFFERS = 54;
static const DeviceCommandId_t LOGGING_CLEAR_COUNTERS = 55;
static const DeviceCommandId_t LOGGING_SET_TOPIC = 56;
2023-11-08 10:46:59 +01:00
static constexpr DeviceCommandId_t REQUEST_ADC_REPORT = 57;
2022-04-28 11:27:28 +02:00
static const DeviceCommandId_t RESET_PL = 58;
2022-05-05 19:18:39 +02:00
static const DeviceCommandId_t ENABLE_NVMS = 59;
2022-05-23 12:05:42 +02:00
static const DeviceCommandId_t CONTINUE_UPDATE = 60;
2022-08-22 13:50:24 +02:00
static const DeviceCommandId_t MEMORY_CHECK_WITH_FILE = 61;
2022-11-28 16:24:18 +01:00
static constexpr DeviceCommandId_t MEMORY_CHECK = 62;
/** Reply IDs */
2022-11-08 19:53:26 +01:00
enum ReplyId : DeviceCommandId_t {
ACK_REPORT = 100,
EXE_REPORT = 101,
HK_REPORT = 102,
BOOT_STATUS_REPORT = 103,
LATCHUP_REPORT = 104,
2023-11-08 10:46:59 +01:00
COUNTERS_REPORT = 105,
2022-11-08 19:53:26 +01:00
ADC_REPORT = 106,
UPDATE_STATUS_REPORT = 107,
};
2022-04-13 11:56:37 +02:00
// Size of complete space packet (6 byte header + size of data + 2 byte CRC)
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
2022-04-06 07:10:20 +02:00
static const uint16_t SIZE_BOOT_STATUS_REPORT = 24;
static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 31;
2023-11-08 10:46:59 +01:00
static const uint16_t SIZE_COUNTERS_REPORT = 120;
2022-04-21 16:30:23 +02:00
static const uint16_t SIZE_ADC_REPORT = 72;
2022-08-24 19:54:16 +02:00
// 2 bits APID SRC, 00 for OBC, 2 bits APID DEST, 01 for SUPV, 7 bits CMD ID -> Mask 0x080
static constexpr uint16_t APID_TC_SUPV_MASK = 0x080;
2022-11-08 14:26:52 +01:00
enum Apid {
2022-11-07 13:37:51 +01:00
TMTC_MAN = 0x00,
HK = 0x01,
BOOT_MAN = 0x02,
LATCHUP_MON = 0x03,
ADC_MON = 0x04,
MEM_MAN = 0x05,
DATA_LOGGER = 0x06,
WDOG_MAN = 0x07
};
2022-11-07 09:26:36 +01:00
2022-11-08 11:08:21 +01:00
namespace tc {
enum class HkId : uint8_t {
2022-11-07 09:26:36 +01:00
ENABLE = 0x01,
SET_PERIOD = 0x02,
GET_REPORT = 0x03,
GET_HARDFAULTS_REPORT = 0x04,
};
2022-11-08 11:08:21 +01:00
enum class TmtcId : uint8_t {
TIME_REF = 0x03,
GET_SUPV_VERSION = 0x05,
RUN_AUTO_EM_TEST = 0x08,
SET_GPIO = 0x0E,
READ_GPIO = 0x0F,
GET_MPSOC_POWER_INFO = 0x10
2022-11-07 09:26:36 +01:00
};
2022-11-08 11:08:21 +01:00
enum class BootManId : uint8_t {
2022-11-07 09:26:36 +01:00
START_MPSOC = 0x01,
SHUTDOWN_MPSOC = 0x02,
SELECT_IMAGE = 0x03,
SET_BOOT_TIMEOUT = 0x04,
SET_MAX_REBOOT_TRIES = 0x05,
RESET_MPSOC = 0x06,
RESET_PL = 0x07,
GET_BOOT_STATUS_REPORT = 0x08,
PREPARE_UPDATE = 0x09,
SHUTDOWN_TIMEOUT = 0x0B,
FACTORY_FLASH = 0x0C
};
2022-11-08 11:08:21 +01:00
enum class LatchupMonId : uint8_t {
2022-11-07 09:26:36 +01:00
ENABLE = 0x01,
DISABLE = 0x02,
SET_ALERT_LIMIT = 0x04,
GET_STATUS_REPORT = 0x06
};
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
2022-11-08 11:08:21 +01:00
enum class AdcMonId : uint8_t {
2022-11-07 13:37:51 +01:00
SET_SWEEP_PERIOD = 0x01,
SET_ENABLED_CHANNELS = 0x02,
SET_WINDOW_STRIDE = 0x03,
SET_ADC_THRESHOLD = 0x04,
2023-11-08 10:46:59 +01:00
COPY_ADC_DATA_TO_MRAM = 0x05,
REQUEST_ADC_SAMPLE = 0x06
2022-11-07 13:37:51 +01:00
};
2022-11-07 09:26:36 +01:00
2022-11-08 11:08:21 +01:00
enum class MemManId : uint8_t { ERASE = 0x01, WRITE = 0x02, CHECK = 0x03 };
2022-11-07 17:31:16 +01:00
2022-11-08 11:08:21 +01:00
enum class DataLoggerServiceId : uint8_t {
2023-11-08 10:46:59 +01:00
// Not implemented.
READ_MRAM_CFG_DATA_LOGGER = 0x00,
REQUEST_COUNTERS = 0x01,
// Not implemented.
EVENT_BUFFER_DOWNLOAD = 0x02,
2022-11-07 17:31:16 +01:00
WIPE_MRAM = 0x05,
DUMP_MRAM = 0x06,
FACTORY_RESET = 0x07
};
2022-11-07 09:26:36 +01:00
// Right now, none of the commands seem to be implemented, but still
// keep the enum here in case some are added
2022-11-08 11:08:21 +01:00
enum class WdogManServiceId : uint8_t {};
} // namespace tc
namespace tm {
enum class TmtcId : uint8_t { ACK = 0x01, NAK = 0x02, EXEC_ACK = 0x03, EXEC_NAK = 0x04 };
enum class HkId : uint8_t { REPORT = 0x01, HARDFAULTS = 0x02 };
enum class BootManId : uint8_t { BOOT_STATUS_REPORT = 0x01 };
2023-11-08 10:46:59 +01:00
enum class AdcMonId : uint8_t { ADC_REPORT = 0x01 };
2022-11-08 11:08:21 +01:00
enum class MemManId : uint8_t { UPDATE_STATUS_REPORT = 0x01 };
enum class LatchupMonId : uint8_t { LATCHUP_STATUS_REPORT = 0x01 };
2023-11-08 10:46:59 +01:00
enum class DataLoggerId : uint8_t { COUNTERS_REPORT = 0x01 };
2022-11-08 11:08:21 +01:00
} // namespace tm
2022-11-07 09:26:36 +01:00
2022-11-11 11:06:08 +01:00
enum class GeneralStatusCode : uint32_t {
OK = 0x000,
NAK = 0x001,
INIT_ERROR = 0x002,
BAD_PARAM = 0x003,
NOT_INITIALIZED = 0x004,
BAD_PERIPH_ID = 0x005,
TIMEOUT = 0x006,
RX_ERROR = 0x007,
TX_ERROR = 0x008,
ARB_LOST = 0x009,
BUSY = 0x00A,
NOT_IMPL = 0x00B,
ALIGNMENT_ERROR = 0x00C,
PERIPH_ERROR = 0x00D,
FAILED_LATCH = 0x00E,
GPIO_HIGH = 0x00F,
GPIO_LOW = 0x010,
TEST_PASSED = 0x011,
TEST_FAILED = 0x012,
BAD_NOF_PARAMS = 0x013,
NULL_POINTER = 0x014,
TASK_CREATION_ERROR = 0x015,
CORRUPTED_MRAM_VAL = 0x016,
BUF_EMPTY = 0x017
};
enum class BootManStatusCode : uint32_t {
NOTHING_TODO = 0x100,
POWER_FAULT = 0x101,
INVALID_LENGTH = 0x102,
OUT_OF_RANGE = 0x103,
OUT_OF_HEAP_MEMORY = 0x104,
INVALID_STATE_TRANSITION = 0x105,
MPSOC_ALREADY_BOOTING = 0x106,
MPSOC_ALREADY_OPERATIONAL = 0x107,
MPSOC_BOOT_FAILED = 0x108,
};
enum class MemManStatusCode : uint32_t {
SP_NOT_AVAILABLE = 0x200,
SP_DATA_INSUFFICIENT = 0x201,
SP_MEMORY_ID_INVALID = 0x202,
MPSOC_NOT_IN_RESET = 0x203,
FLASH_INIT_FAILED = 0x204,
FLASH_ERASE_FAILED = 0x205,
FLASH_WRITE_FAILED = 0x206,
FLASH_VERIFY_FAILED = 0x207,
CANNOT_ACCESS_TM = 0x208,
CANNOT_SEND_TM = 0x209,
};
enum class PowerManStatusCode : uint32_t {
PG_LOW = 0x300,
PG_5V_LOW = 0x301,
PG_0V85_LOW = 0x302,
PG_1V8_LOW = 0x303,
PG_MISC_LOW = 0x304,
PG_3V3_LOW = 0x305,
PG_MB_VAIO_LOW = 0x306,
PG_MB_MPSOCIO_LOW = 0x307
};
enum class TmtcManStatusCode : uint32_t {
BUF_FULL = 0x600,
WRONG_APID = 0x601,
WRONG_SERVICE_ID = 0x602,
TC_DELIVERY_ACCEPTED = 0x603,
TC_DELIVERY_REJECTED = 0x0604,
TC_PACKET_LEN_INCORRECT = 0x605,
BAD_CRC = 0x606,
BAD_DEST = 0x607,
BAD_SP_HEADER = 0x608
};
2022-11-17 13:58:40 +01:00
static constexpr uint16_t APID_MASK_TC = 0x80;
static constexpr uint16_t APID_MASK_TM = 0x200;
2022-11-17 13:24:39 +01:00
static constexpr uint16_t APID_MODULE_MASK = 0x7F;
2021-08-08 15:02:59 +02:00
static const uint16_t SEQUENCE_COUNT_MASK = 0xFFF;
2021-08-01 17:11:32 +02:00
2022-11-07 10:30:09 +01:00
static const uint8_t HK_SET_ENTRIES = 13;
static const uint8_t BOOT_REPORT_SET_ENTRIES = 10;
static const uint8_t LATCHUP_RPT_SET_ENTRIES = 16;
2023-11-08 18:19:24 +01:00
static const uint8_t LOGGING_RPT_SET_ENTRIES = 30;
2022-11-07 10:30:09 +01:00
static const uint8_t ADC_RPT_SET_ENTRIES = 32;
2022-11-07 10:30:09 +01:00
static const uint32_t HK_SET_ID = HK_REPORT;
static const uint32_t BOOT_REPORT_SET_ID = BOOT_STATUS_REPORT;
static const uint32_t LATCHUP_RPT_ID = LATCHUP_REPORT;
2023-11-08 10:46:59 +01:00
static const uint32_t LOGGING_RPT_ID = COUNTERS_REPORT;
2022-11-07 10:30:09 +01:00
static const uint32_t ADC_REPORT_SET_ID = ADC_REPORT;
2022-11-08 11:08:21 +01:00
namespace timeout {
2022-11-07 10:30:09 +01:00
// Erase memory can require up to 60 seconds for execution
static const uint32_t ERASE_MEMORY = 60000;
static const uint32_t UPDATE_STATUS_REPORT = 70000;
2022-11-08 16:26:30 +01:00
static const uint32_t CRC_EXECUTION_TIMEOUT = 60000;
2022-11-08 11:08:21 +01:00
} // namespace timeout
2022-11-07 10:30:09 +01:00
static constexpr size_t TIMESTAMP_LEN = 7;
static constexpr size_t SECONDARY_HEADER_LEN = TIMESTAMP_LEN + 1;
static constexpr size_t CRC_LEN = 2;
/** This is the maximum length of a space packet as defined by the TAS ICD */
static const size_t MAX_COMMAND_SIZE = 1024;
2021-07-31 08:32:57 +02:00
static const size_t MAX_DATA_CAPACITY = 1016;
/** This is the maximum size of a space packet for the supervisor */
static const size_t MAX_PACKET_SIZE = 1024;
2022-11-07 10:30:09 +01:00
static constexpr size_t MIN_PAYLOAD_LEN = SECONDARY_HEADER_LEN + CRC_LEN;
2022-11-08 10:22:57 +01:00
static constexpr size_t MIN_TMTC_LEN = ccsds::HEADER_LEN + MIN_PAYLOAD_LEN;
2022-11-07 10:30:09 +01:00
static constexpr size_t PAYLOAD_OFFSET = ccsds::HEADER_LEN + SECONDARY_HEADER_LEN;
2022-11-08 20:37:57 +01:00
enum class FactoryResetSelect : uint8_t {
EVENT_BUF = 0x00,
ADC_BUF = 0x01,
SYS_CFG = 0x02,
DEBUG_CFG = 0x03,
BOOT_MAN_CFG = 0x04,
DATA_LOGGER_CFG = 0x05,
DATA_LOGGER_OP_DATA = 0x06,
LATCHUP_MON_CFG = 0x07,
ADC_MON_CFG = 0x08,
WDOG_MAN_CFG = 0x09,
HK_CFG = 0x0A,
MEM_MAN_CFG = 0xB9
};
2022-08-24 12:02:16 +02:00
struct UpdateParams {
std::string file;
uint8_t memId;
uint32_t startAddr;
uint32_t bytesWritten;
uint16_t seqCount;
bool deleteMemory;
};
2022-01-17 15:58:27 +01:00
enum PoolIds : lp_id_t {
NUM_TMS,
TEMP_PS,
TEMP_PL,
2022-04-11 16:52:50 +02:00
HK_SOC_STATE,
2022-01-17 15:58:27 +01:00
NVM0_1_STATE,
NVM3_STATE,
MISSION_IO_STATE,
FMC_STATE,
NUM_TCS,
TEMP_SUP,
UPTIME,
CPULOAD,
AVAILABLEHEAP,
2022-04-11 16:52:50 +02:00
BR_SOC_STATE,
POWER_CYCLES,
2022-01-17 15:58:27 +01:00
BOOT_AFTER_MS,
2023-11-09 17:19:28 +01:00
BOOT_TIMEOUT_POOL_VAR_MS,
2022-01-17 15:58:27 +01:00
ACTIVE_NVM,
BP0_STATE,
BP1_STATE,
BP2_STATE,
2022-04-06 07:10:20 +02:00
BOOT_STATE,
BOOT_CYCLES,
2022-01-17 15:58:27 +01:00
LATCHUP_ID,
CNT0,
CNT1,
CNT2,
CNT3,
CNT4,
CNT5,
CNT6,
LATCHUP_RPT_TIME_SEC,
LATCHUP_RPT_TIME_MIN,
LATCHUP_RPT_TIME_HOUR,
LATCHUP_RPT_TIME_DAY,
LATCHUP_RPT_TIME_MON,
LATCHUP_RPT_TIME_YEAR,
LATCHUP_RPT_TIME_MSEC,
2022-04-11 16:52:50 +02:00
LATCHUP_RPT_IS_SET,
2022-04-13 11:56:37 +02:00
2023-11-08 10:46:59 +01:00
SIGNATURE,
LATCHUP_HAPPENED_CNTS,
2022-04-22 08:55:57 +02:00
ADC_DEVIATION_TRIGGERS_CNT,
TC_RECEIVED_CNT,
TM_AVAILABLE_CNT,
SUPERVISOR_BOOTS,
MPSOC_BOOTS,
MPSOC_BOOT_FAILED_ATTEMPTS,
MPSOC_POWER_UP,
MPSOC_UPDATES,
2023-11-08 10:46:59 +01:00
MPSOC_HEARTBEAT_RESETS,
CPU_WDT_RESETS,
PS_HEARTBEATS_LOST,
PL_HEARTBEATS_LOST,
EB_TASK_LOST,
BM_TASK_LOST,
LM_TASK_LOST,
AM_TASK_LOST,
TCTMM_TASK_LOST,
MM_TASK_LOST,
HK_TASK_LOST,
DL_TASK_LOST,
RWS_TASKS_LOST,
ADC_RAW,
ADC_ENG,
};
2022-11-07 11:19:10 +01:00
struct TcParams : public ploc::SpTcParams {
2022-11-04 14:19:58 +01:00
public:
2022-11-07 11:19:10 +01:00
TcParams(SpacePacketCreator& creator) : ploc::SpTcParams(creator) {}
2022-11-04 14:19:58 +01:00
2022-11-07 11:19:10 +01:00
TcParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
2022-11-04 14:19:58 +01:00
: ploc::SpTcParams(creator, buf, maxSize) {}
void setLenFromPayloadLen(size_t payloadLen) {
2022-11-07 10:30:09 +01:00
setFullPayloadLen(ccsds::HEADER_LEN + SECONDARY_HEADER_LEN + payloadLen + CRC_LEN);
2022-11-04 14:19:58 +01:00
}
};
2022-11-07 11:19:10 +01:00
class TcBase : public ploc::SpTcBase {
2022-11-04 14:19:58 +01:00
public:
2022-11-07 13:37:51 +01:00
TcBase(TcParams params) : TcBase(params, 0x00, 0x00, MIN_PAYLOAD_LEN) {}
TcBase(TcParams params, uint16_t apid) : TcBase(params, apid, 0x00, MIN_PAYLOAD_LEN) {}
TcBase(TcParams params, uint16_t apid, uint8_t service, size_t payloadLen)
: TcBase(params, apid, service, payloadLen, DEFAULT_SEQ_COUNT) {}
2022-11-04 14:19:58 +01:00
2022-11-07 13:37:51 +01:00
TcBase(TcParams params, uint16_t apid, uint8_t serviceId, size_t payloadLen, uint16_t seqCount)
2022-11-17 13:24:39 +01:00
: ploc::SpTcBase(params, apid | APID_MASK_TC, fullSpDataLenFromPayloadLen(payloadLen),
seqCount) {
2022-11-07 13:37:51 +01:00
setup(serviceId);
}
void setServiceId(uint8_t id) {
if (spParams.maxSize < MIN_PAYLOAD_LEN) {
return;
2022-11-07 10:30:09 +01:00
}
2022-11-07 13:37:51 +01:00
payloadStart[supv::PAYLOAD_OFFSET] = id;
}
2022-11-17 13:24:39 +01:00
uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; }
2022-11-18 17:25:52 +01:00
uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; }
2022-11-08 16:26:30 +01:00
2022-11-07 13:37:51 +01:00
static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) {
return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN;
2022-11-07 10:30:09 +01:00
}
2022-11-07 09:26:36 +01:00
2022-11-07 11:26:36 +01:00
void setLenFromPayloadLen(size_t payloadLen) {
2022-11-07 13:37:51 +01:00
spParams.setFullPayloadLen(fullSpDataLenFromPayloadLen(payloadLen));
updateLenFromParams();
2022-11-07 11:26:36 +01:00
}
2022-11-04 14:19:58 +01:00
private:
2022-11-07 13:37:51 +01:00
ReturnValue_t setup(uint8_t serviceId) {
2022-11-07 10:30:09 +01:00
if (spParams.maxSize < MIN_PAYLOAD_LEN) {
sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl;
return returnvalue::FAILED;
}
std::memset(spParams.buf + ccsds::HEADER_LEN, 0, TIMESTAMP_LEN);
2022-11-07 13:37:51 +01:00
payloadStart = spParams.buf + ccsds::HEADER_LEN + SECONDARY_HEADER_LEN;
2022-11-17 13:58:40 +01:00
spParams.buf[ccsds::HEADER_LEN + SECONDARY_HEADER_LEN - 1] = serviceId;
spParams.creator.setSecHeaderFlag();
2022-11-07 10:30:09 +01:00
return returnvalue::OK;
}
2022-11-04 14:19:58 +01:00
};
2022-11-08 11:08:21 +01:00
class TmBase : public ploc::SpTmReader {
public:
2022-11-08 14:26:52 +01:00
TmBase() = default;
2022-11-08 11:08:21 +01:00
TmBase(const uint8_t* data, size_t maxSize) : ploc::SpTmReader(data, maxSize) {
if (maxSize < MIN_TMTC_LEN) {
2022-11-08 10:22:57 +01:00
sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl;
}
}
2022-11-08 11:08:21 +01:00
uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; }
2022-11-08 10:22:57 +01:00
2022-11-17 13:24:39 +01:00
uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; }
2022-11-08 11:08:21 +01:00
const uint8_t* getPayloadStart() const { return getPacketData() + SECONDARY_HEADER_LEN; }
2022-11-08 16:56:42 +01:00
size_t getPayloadLen() const {
if (getFullPacketLen() > SECONDARY_HEADER_LEN + ccsds::HEADER_LEN) {
return getFullPacketLen() - SECONDARY_HEADER_LEN - ccsds::HEADER_LEN;
}
return 0;
}
2022-11-08 10:22:57 +01:00
};
2022-11-07 11:19:10 +01:00
class NoPayloadPacket : public TcBase {
2022-11-07 10:30:09 +01:00
public:
2022-11-07 11:19:10 +01:00
NoPayloadPacket(TcParams params, uint16_t apid, uint8_t serviceId)
: NoPayloadPacket(params, apid, serviceId, 0) {}
2022-11-07 10:30:09 +01:00
2022-11-07 11:19:10 +01:00
NoPayloadPacket(TcParams params, uint16_t apid, uint8_t serviceId, uint16_t seqId)
2022-11-07 13:37:51 +01:00
: TcBase(params, apid, serviceId, MIN_PAYLOAD_LEN, seqId) {}
2022-11-07 10:30:09 +01:00
ReturnValue_t buildPacket() {
ReturnValue_t result = checkSizeAndSerializeHeader();
2022-11-08 19:53:26 +01:00
if (result != returnvalue::OK) {
2022-11-07 10:30:09 +01:00
return result;
}
return calcAndSetCrc();
}
private:
};
/**
* @brief This class can be used to generate the space packet selecting the boot image of
* of the MPSoC.
*/
2022-11-07 11:26:36 +01:00
class MPSoCBootSelect : public TcBase {
2022-01-17 15:58:27 +01:00
public:
2022-05-17 13:40:19 +02:00
static const uint8_t NVM0 = 0;
static const uint8_t NVM1 = 1;
2022-05-13 18:37:16 +02:00
2022-01-17 15:58:27 +01:00
/**
* @brief Constructor
*
* @param mem The memory to boot from: NVM0 (0), NVM1 (1)
* @param bp0 Partition pin 0
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
2022-05-23 12:05:42 +02:00
*
* @note Selection of partitions is currently not supported.
2022-01-17 15:58:27 +01:00
*/
2022-11-07 13:37:51 +01:00
MPSoCBootSelect(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SELECT_IMAGE), 4) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
2022-08-15 13:03:23 +02:00
initPacket(mem, bp0, bp1, bp2);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
2022-08-15 13:03:23 +02:00
void initPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) {
2022-11-07 11:26:36 +01:00
payloadStart[0] = mem;
2022-11-07 13:37:51 +01:00
payloadStart[1] = bp0;
payloadStart[2] = bp1;
payloadStart[3] = bp2;
2022-01-17 15:58:27 +01:00
}
};
/**
* @brief This class generates the space packet to update the time of the PLOC supervisor.
*/
2022-11-07 13:37:51 +01:00
class SetTimeRef : public TcBase {
2022-01-17 15:58:27 +01:00
public:
2022-11-07 13:37:51 +01:00
static constexpr size_t PAYLOAD_LEN = 8;
SetTimeRef(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::TIME_REF), 8) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(Clock::TimeOfDay_t* time) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
2022-08-15 13:03:23 +02:00
return res;
}
2022-08-18 15:32:24 +02:00
res = initPacket(time);
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return res;
}
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
2022-04-06 07:10:20 +02:00
static const uint16_t SYNC = 0x8000;
2022-01-17 15:58:27 +01:00
2022-08-18 15:32:24 +02:00
ReturnValue_t initPacket(Clock::TimeOfDay_t* time) {
size_t serializedSize = 6;
2022-08-15 13:03:23 +02:00
uint8_t* dataFieldPtr = payloadStart;
2022-04-06 07:10:20 +02:00
uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC;
2022-08-18 15:32:24 +02:00
ReturnValue_t result =
SerializeAdapter::serialize(&milliseconds, &dataFieldPtr, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return result;
}
2022-04-06 07:10:20 +02:00
uint8_t second = static_cast<uint8_t>(time->second);
2022-08-18 15:32:24 +02:00
result = SerializeAdapter::serialize(&second, &dataFieldPtr, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return result;
}
2022-04-06 07:10:20 +02:00
uint8_t minute = static_cast<uint8_t>(time->minute);
2022-08-18 15:32:24 +02:00
result = SerializeAdapter::serialize(&minute, &dataFieldPtr, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return result;
}
2022-04-06 07:10:20 +02:00
uint8_t hour = static_cast<uint8_t>(time->hour);
2022-08-18 15:32:24 +02:00
result = SerializeAdapter::serialize(&hour, &dataFieldPtr, &serializedSize, spParams.maxSize,
2022-04-11 16:52:50 +02:00
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return result;
}
2022-04-06 07:10:20 +02:00
uint8_t day = static_cast<uint8_t>(time->day);
2022-08-18 15:32:24 +02:00
result = SerializeAdapter::serialize(&day, &dataFieldPtr, &serializedSize, spParams.maxSize,
2022-04-06 07:10:20 +02:00
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return result;
}
2022-04-06 07:10:20 +02:00
uint8_t month = static_cast<uint8_t>(time->month);
2022-08-18 15:32:24 +02:00
result = SerializeAdapter::serialize(&month, &dataFieldPtr, &serializedSize, spParams.maxSize,
2022-04-11 16:52:50 +02:00
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-18 15:32:24 +02:00
return result;
}
uint8_t year = static_cast<uint8_t>(time->year - 1900);
return SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-01-17 15:58:27 +01:00
}
};
/**
* @brief This class can be used to generate the set boot timout command.
*/
2022-11-07 13:37:51 +01:00
class SetBootTimeout : public TcBase {
2022-01-17 15:58:27 +01:00
public:
2022-11-07 13:37:51 +01:00
static constexpr size_t PAYLOAD_LEN = 4;
2022-01-17 15:58:27 +01:00
/**
* @brief Constructor
*
* @param timeout The boot timeout in milliseconds.
*/
2022-11-07 13:37:51 +01:00
SetBootTimeout(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_BOOT_TIMEOUT),
2022-11-07 13:37:51 +01:00
PAYLOAD_LEN) {}
2022-01-17 15:58:27 +01:00
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(uint32_t timeout) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
2022-08-15 13:03:23 +02:00
return res;
}
initPacket(timeout);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-08-15 13:03:23 +02:00
}
2022-01-17 15:58:27 +01:00
2022-08-15 13:03:23 +02:00
private:
void initPacket(uint32_t timeout) {
2022-01-17 15:58:27 +01:00
size_t serializedSize = 0;
2022-08-15 13:03:23 +02:00
uint8_t* dataFieldPtr = payloadStart;
2022-04-11 16:52:50 +02:00
SerializeAdapter::serialize<uint32_t>(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout),
SerializeIF::Endianness::BIG);
2022-01-17 15:58:27 +01:00
}
};
2022-11-08 20:37:57 +01:00
class FactoryReset : public TcBase {
public:
FactoryReset(TcParams params)
: TcBase(params, Apid::DATA_LOGGER,
static_cast<uint8_t>(tc::DataLoggerServiceId::FACTORY_RESET), 0) {}
2022-12-23 10:13:26 +01:00
ReturnValue_t buildPacket(uint8_t op) {
setLenFromPayloadLen(1);
2022-11-08 20:37:57 +01:00
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
2022-12-23 10:13:26 +01:00
payloadStart[0] = op;
2022-11-08 20:37:57 +01:00
return calcAndSetCrc();
}
private:
};
2021-07-22 08:06:04 +02:00
/**
* @brief This class can be used to generate the space packet to set the maximum boot tries.
*/
2022-11-07 13:37:51 +01:00
class SetRestartTries : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param restartTries Maximum restart tries to set.
*/
2022-11-07 13:37:51 +01:00
SetRestartTries(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SET_MAX_REBOOT_TRIES),
2022-11-08 11:08:21 +01:00
1) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(uint8_t restartTries) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
2022-08-15 13:03:23 +02:00
return res;
}
initPacket(restartTries);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
void initPacket(uint8_t restartTries) { payloadStart[0] = restartTries; }
2021-07-22 08:06:04 +02:00
};
/**
* @brief With this class the space packet can be generated to disable to periodic transmission
* of housekeeping data. Normally, this will be disabled by default. However, adding this
* command can be useful for debugging.
*/
2022-11-07 13:37:51 +01:00
class DisablePeriodicHkTransmission : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*/
2022-11-07 13:37:51 +01:00
DisablePeriodicHkTransmission(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::HK, static_cast<uint8_t>(tc::HkId::ENABLE), 1) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket() {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
2022-08-15 13:03:23 +02:00
return res;
}
2022-01-17 15:58:27 +01:00
initPacket();
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
void initPacket() { payloadStart[0] = false; }
};
/**
* @brief This class packages the command to enable of disable the latchup alert.
*
* @details There are 7 different latchup alerts.
*/
2022-11-07 13:37:51 +01:00
class LatchupAlert : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param state true - enable, false - disable
* @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC,
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
*/
2022-11-08 14:26:52 +01:00
LatchupAlert(TcParams params) : TcBase(params, Apid::LATCHUP_MON) { setLenFromPayloadLen(1); }
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(bool state, uint8_t latchupId) {
2022-01-17 15:58:27 +01:00
if (state) {
2022-11-08 11:08:21 +01:00
setServiceId(static_cast<uint8_t>(tc::LatchupMonId::ENABLE));
2022-01-17 15:58:27 +01:00
} else {
2022-11-08 11:08:21 +01:00
setServiceId(static_cast<uint8_t>(tc::LatchupMonId::DISABLE));
2022-01-17 15:58:27 +01:00
}
2022-08-15 13:03:23 +02:00
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
2022-08-15 13:03:23 +02:00
return res;
}
initPacket(latchupId);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; }
};
2022-11-07 13:37:51 +01:00
class SetAlertlimit : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param latchupId Identifies the latchup alert to calibrate (0 - 0.85V, 1 - 1.8V, 2 - MISC,
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
* @param dutycycle
*/
2022-11-07 13:37:51 +01:00
SetAlertlimit(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::LATCHUP_MON, static_cast<uint8_t>(tc::LatchupMonId::SET_ALERT_LIMIT),
2022-11-08 11:08:21 +01:00
5) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(uint8_t latchupId, uint32_t dutycycle) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
res = initPacket(latchupId, dutycycle);
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
}
2022-01-17 15:58:27 +01:00
private:
2022-08-15 13:03:23 +02:00
ReturnValue_t initPacket(uint8_t latchupId, uint32_t dutycycle) {
payloadStart[0] = latchupId;
size_t serLen = 0;
return SerializeAdapter::serialize<uint32_t>(&dutycycle, payloadStart + 1, &serLen,
sizeof(dutycycle), SerializeIF::Endianness::BIG);
2022-01-17 15:58:27 +01:00
}
};
/**
* @brief This class packages the space packet to configures the window size and striding step of
* the moving average filter applied to the ADC readings.
*/
2022-11-07 17:31:16 +01:00
class SetAdcWindowAndStride : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param windowSize
* @param stridingStepSize
*/
2022-11-07 17:31:16 +01:00
SetAdcWindowAndStride(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_WINDOW_STRIDE), 4) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(uint16_t windowSize, uint16_t stridingStepSize) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(windowSize, stridingStepSize);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
}
2022-01-17 15:58:27 +01:00
private:
2022-08-15 13:03:23 +02:00
void initPacket(uint16_t windowSize, uint16_t stridingStepSize) {
2022-08-20 12:11:08 +02:00
size_t serializedSize = 6;
2022-08-15 13:03:23 +02:00
uint8_t* data = payloadStart;
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&windowSize, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&stridingStepSize, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-01-17 15:58:27 +01:00
}
};
/**
* @brief This class packages the space packet to set the ADC trigger threshold.
*/
2022-11-07 17:31:16 +01:00
class SetAdcThreshold : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param threshold
*/
2022-11-07 17:31:16 +01:00
SetAdcThreshold(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ADC_THRESHOLD), 4) {}
ReturnValue_t buildPacket(uint32_t threshold) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(threshold);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
}
2022-01-17 15:58:27 +01:00
private:
2022-08-15 13:03:23 +02:00
void initPacket(uint32_t threshold) {
2022-01-17 15:58:27 +01:00
size_t serializedSize = 0;
SerializeAdapter::serialize(&threshold, payloadStart, &serializedSize, sizeof(threshold),
SerializeIF::Endianness::BIG);
2022-01-17 15:58:27 +01:00
}
2021-07-28 11:55:16 +02:00
};
2021-07-28 19:34:10 +02:00
/**
* @brief This class packages the space packet to run auto EM tests.
*/
2022-11-07 17:31:16 +01:00
class RunAutoEmTests : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
*/
2022-11-07 17:31:16 +01:00
RunAutoEmTests(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::RUN_AUTO_EM_TEST), 1) {}
2022-08-15 13:03:23 +02:00
ReturnValue_t buildPacket(uint8_t test) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(test);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
}
2022-01-17 15:58:27 +01:00
private:
uint8_t test = 0;
void initPacket(uint8_t test) { payloadStart[0] = test; }
2021-07-28 19:34:10 +02:00
};
2022-11-09 19:24:48 +01:00
/**
* @brief This class packages the space packet to enable or disable ADC channels.
*/
class SetAdcEnabledChannels : public TcBase {
public:
/**
* @brief Constructor
*
* @param ch Defines channels to be enabled or disabled.
*/
SetAdcEnabledChannels(TcParams params)
: TcBase(params, Apid::ADC_MON, static_cast<uint8_t>(tc::AdcMonId::SET_ENABLED_CHANNELS), 2) {
}
ReturnValue_t buildPacket(uint16_t ch) {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
initPacket(ch);
return calcAndSetCrc();
}
private:
void initPacket(uint16_t ch) {
size_t serializedSize = 0;
SerializeAdapter::serialize(&ch, &payloadStart, &serializedSize, sizeof(ch),
SerializeIF::Endianness::BIG);
}
};
2021-08-02 15:28:57 +02:00
/**
* @brief This class packages the space packet change the state of a GPIO. This command is only
* required for ground testing.
*/
2022-11-07 17:31:16 +01:00
class SetGpio : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param port
* @param pin
* @param val
*/
2022-11-07 17:31:16 +01:00
SetGpio(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::SET_GPIO), 3) {}
ReturnValue_t buildPacket(uint8_t port, uint8_t pin, uint8_t val) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(port, pin, val);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
uint8_t port = 0;
uint8_t pin = 0;
uint8_t val = 0;
void initPacket(uint8_t port, uint8_t pin, uint8_t val) {
payloadStart[0] = port;
payloadStart[1] = pin;
payloadStart[2] = val;
2022-01-17 15:58:27 +01:00
}
2021-08-02 15:28:57 +02:00
};
/**
* @brief This class packages the space packet causing the supervisor print the state of a GPIO
* to the debug output.
*/
2022-11-07 17:31:16 +01:00
class ReadGpio : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
* @param port
* @param pin
*/
2022-11-07 17:31:16 +01:00
ReadGpio(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::TMTC_MAN, static_cast<uint8_t>(tc::TmtcId::READ_GPIO), 2) {}
ReturnValue_t buildPacket(uint8_t port, uint8_t pin) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(port, pin);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
uint8_t port = 0;
uint8_t pin = 0;
void initPacket(uint8_t port, uint8_t pin) {
payloadStart[0] = port;
payloadStart[1] = pin;
2022-01-17 15:58:27 +01:00
}
2021-08-02 15:28:57 +02:00
};
2022-11-07 17:31:16 +01:00
class SetShutdownTimeout : public TcBase {
2022-01-17 15:58:27 +01:00
public:
2022-11-07 17:31:16 +01:00
SetShutdownTimeout(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::BOOT_MAN, static_cast<uint8_t>(tc::BootManId::SHUTDOWN_TIMEOUT), 4) {}
2022-01-17 15:58:27 +01:00
ReturnValue_t buildPacket(uint32_t timeout) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(timeout);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-04-11 16:52:50 +02:00
}
private:
void initPacket(uint32_t timeout) {
size_t serLen = 0;
SerializeAdapter::serialize(&timeout, payloadStart, &serLen, sizeof(timeout),
SerializeIF::Endianness::BIG);
2022-04-11 16:52:50 +02:00
}
};
2021-08-05 16:37:39 +02:00
/**
2022-04-10 18:46:39 +02:00
* @brief Command to request CRC over memory region of the supervisor.
2021-08-05 16:37:39 +02:00
*/
2022-11-07 17:31:16 +01:00
class CheckMemory : public TcBase {
2022-01-17 15:58:27 +01:00
public:
/**
* @brief Constructor
*
2022-04-10 18:46:39 +02:00
* @param memoryId
* @param startAddress Start address of CRC calculation
* @param length Length in bytes of memory region
2022-01-17 15:58:27 +01:00
*/
2022-11-07 17:31:16 +01:00
CheckMemory(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::MEM_MAN, static_cast<uint8_t>(tc::MemManId::CHECK), 10) {}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(memoryId, startAddress, length);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-01-17 15:58:27 +01:00
}
private:
2022-04-10 18:46:39 +02:00
uint8_t n = 1;
2022-01-17 15:58:27 +01:00
void initPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
uint8_t* data = payloadStart;
2022-08-20 12:11:08 +02:00
size_t serLen = 6;
SerializeAdapter::serialize(&memoryId, &data, &serLen, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&n, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG);
SerializeAdapter::serialize(&startAddress, &data, &serLen, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&length, &data, &serLen, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-01-17 15:58:27 +01:00
}
2021-08-05 16:37:39 +02:00
};
/**
* @brief This class packages the space packet transporting a part of an MPSoC update.
*/
2022-11-07 17:31:16 +01:00
class WriteMemory : public TcBase {
2022-01-17 15:58:27 +01:00
public:
2022-04-10 18:46:39 +02:00
/**
* @brief Constructor
*
* @param seqFlags Sequence flags
* @param sequenceCount Sequence count (first update packet expects 1 as sequence count)
* @param updateData Pointer to buffer containing update data
*/
2022-11-07 17:31:16 +01:00
WriteMemory(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::MEM_MAN, static_cast<uint8_t>(tc::MemManId::WRITE), 1) {}
ReturnValue_t buildPacket(ccsds::SequenceFlags seqFlags, uint16_t sequenceCount, uint8_t memoryId,
uint32_t startAddress, uint16_t length, uint8_t* updateData) {
2022-08-16 18:13:54 +02:00
if (length > CHUNK_MAX) {
2022-04-10 18:46:39 +02:00
sif::error << "WriteMemory::WriteMemory: Invalid length" << std::endl;
return SerializeIF::BUFFER_TOO_SHORT;
}
spParams.creator.setSeqFlags(seqFlags);
spParams.creator.setSeqCount(sequenceCount);
auto res = initPacket(memoryId, startAddress, length, updateData);
if (res != returnvalue::OK) {
return res;
}
res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
2022-04-10 18:46:39 +02:00
}
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-04-06 08:36:34 +02:00
}
2022-04-10 18:46:39 +02:00
// Although the space packet has space left for 1010 bytes of data to supervisor can only process
2022-04-24 12:34:08 +02:00
// update packets with a maximum of 512 bytes.
2022-04-10 18:46:39 +02:00
static const uint16_t CHUNK_MAX = 512;
2022-04-06 08:36:34 +02:00
private:
static const uint16_t META_DATA_LENGTH = 8;
uint8_t n = 1;
2022-08-16 18:37:51 +02:00
ReturnValue_t initPacket(uint8_t memoryId, uint32_t startAddr, uint16_t updateDataLen,
2022-08-18 15:32:24 +02:00
uint8_t* updateData) {
uint8_t* data = payloadStart;
2022-08-20 01:45:49 +02:00
if (updateDataLen % 2 != 0) {
2022-11-07 17:31:16 +01:00
setLenFromPayloadLen(META_DATA_LENGTH + updateDataLen + 1);
2022-08-20 01:45:49 +02:00
} else {
2022-11-07 17:31:16 +01:00
setLenFromPayloadLen(META_DATA_LENGTH + updateDataLen);
2022-08-20 01:45:49 +02:00
}
// To avoid crashes in this unexpected case
ReturnValue_t result = checkPayloadLen();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-08-20 01:45:49 +02:00
return result;
}
size_t serializedSize = MIN_TMTC_LEN;
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&n, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&startAddr, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&updateDataLen, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 01:45:49 +02:00
std::memcpy(data, updateData, updateDataLen);
if (updateDataLen % 2 != 0) {
2022-04-10 18:46:39 +02:00
// The data field must be two bytes aligned. Thus, in case the number of bytes to write is odd
// a value of zero is added here
2022-11-28 09:38:32 +01:00
data[updateDataLen] = 0;
2022-08-16 18:37:51 +02:00
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-04-06 08:36:34 +02:00
}
};
2022-11-10 13:50:18 +01:00
/**
* @brief This class packages the space packet to wipe or dump parts of the MRAM.
*/
class MramCmd : public TcBase {
public:
enum class MramAction { WIPE, DUMP };
/**
* @brief Constructor
*
* @param start Start address of the MRAM section to wipe or dump
* @param stop End address of the MRAM section to wipe or dump
* @param action Dump or wipe MRAM
*
* @note The content at the stop address is excluded from the dump or wipe operation.
*/
MramCmd(TcParams params) : TcBase(params, Apid::DATA_LOGGER) { setLenFromPayloadLen(6); }
ReturnValue_t buildPacket(uint32_t start, uint32_t stop, MramAction action) {
if (action == MramAction::WIPE) {
setServiceId(static_cast<uint8_t>(tc::DataLoggerServiceId::WIPE_MRAM));
} else if (action == MramAction::DUMP) {
setServiceId(static_cast<uint8_t>(tc::DataLoggerServiceId::DUMP_MRAM));
} else {
sif::debug << "WipeMram: Invalid action specified";
}
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
initPacket(start, stop);
return calcAndSetCrc();
}
private:
uint32_t start = 0;
uint32_t stop = 0;
void initPacket(uint32_t start, uint32_t stop) {
uint8_t concatBuffer[6];
concatBuffer[0] = static_cast<uint8_t>(start >> 16);
concatBuffer[1] = static_cast<uint8_t>(start >> 8);
concatBuffer[2] = static_cast<uint8_t>(start);
concatBuffer[3] = static_cast<uint8_t>(stop >> 16);
concatBuffer[4] = static_cast<uint8_t>(stop >> 8);
concatBuffer[5] = static_cast<uint8_t>(stop);
std::memcpy(payloadStart, concatBuffer, sizeof(concatBuffer));
}
};
2022-04-11 16:52:50 +02:00
/**
2022-08-20 10:27:43 +02:00
* @brief This class can be used to package erase memory command
2022-04-11 16:52:50 +02:00
*/
2022-11-07 17:31:16 +01:00
class EraseMemory : public TcBase {
2022-04-11 16:52:50 +02:00
public:
2022-11-07 17:31:16 +01:00
EraseMemory(TcParams params)
2022-11-08 14:26:52 +01:00
: TcBase(params, Apid::MEM_MAN, static_cast<uint8_t>(tc::MemManId::ERASE), PAYLOAD_LENGTH) {}
ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
auto res = checkSizeAndSerializeHeader();
2022-08-24 17:27:47 +02:00
if (res != returnvalue::OK) {
return res;
}
initPacket(memoryId, startAddress, length);
2022-11-07 10:30:09 +01:00
return calcAndSetCrc();
2022-04-11 16:52:50 +02:00
}
private:
static const uint16_t PAYLOAD_LENGTH = 10; // length without CRC field
uint8_t n = 1;
void initPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) {
uint8_t* data = payloadStart;
2022-08-20 12:11:08 +02:00
size_t serializedSize = 6;
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&n, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&startAddress, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-08-20 12:11:08 +02:00
SerializeAdapter::serialize(&length, &data, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG);
2022-04-11 16:52:50 +02:00
}
};
2022-11-08 11:08:21 +01:00
class VerificationReport {
public:
2022-11-08 11:08:21 +01:00
VerificationReport(TmBase& readerBase) : readerBase(readerBase) {}
2022-11-08 11:08:21 +01:00
virtual ~VerificationReport() = default;
2023-11-15 11:31:57 +01:00
virtual ReturnValue_t parse(bool checkCrc) {
if (checkCrc and readerBase.checkCrc() != returnvalue::OK) {
return result::CRC_FAILURE;
2022-11-08 11:08:21 +01:00
}
2022-11-17 13:39:59 +01:00
if (readerBase.getModuleApid() != Apid::TMTC_MAN) {
return result::INVALID_APID;
2022-11-08 11:08:21 +01:00
}
2022-11-08 16:56:42 +01:00
if (readerBase.getBufSize() < MIN_TMTC_LEN + PAYLOAD_LEN or
readerBase.getPayloadLen() < PAYLOAD_LEN) {
2022-11-08 11:08:21 +01:00
sif::error << "VerificationReport: Invalid verification report, payload too small"
<< std::endl;
return result::BUF_TOO_SMALL;
2022-11-08 11:08:21 +01:00
}
const uint8_t* payloadStart = readerBase.getPayloadStart();
size_t remLen = PAYLOAD_LEN;
ReturnValue_t result = SerializeAdapter::deSerialize(&refApid, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2023-11-15 11:31:57 +01:00
sif::warning << "VerificationReport: Failed to deserialize reference APID field" << std::endl;
return result;
}
2022-11-08 11:08:21 +01:00
result = SerializeAdapter::deSerialize(&refServiceId, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
2023-11-15 11:31:57 +01:00
sif::warning << "VerificationReport: Failed to deserialize reference Service ID field"
<< std::endl;
2022-11-08 11:08:21 +01:00
return result;
}
result = SerializeAdapter::deSerialize(&refSeqCount, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
if (result != returnvalue::OK) {
2023-11-15 11:31:57 +01:00
sif::warning << "VerificationReport: Failed to deserialize reference sequence count field"
<< std::endl;
2022-11-08 11:08:21 +01:00
return result;
}
result = SerializeAdapter::deSerialize(&statusCode, &payloadStart, &remLen,
SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2023-11-15 11:31:57 +01:00
sif::warning << "VerificationReport: Failed to deserialize status code field" << std::endl;
return result;
}
2022-11-08 11:08:21 +01:00
return returnvalue::OK;
}
2022-11-08 11:08:21 +01:00
/**
* @brief Gets the APID of command which caused the transmission of this verification report.
*/
2022-11-17 13:26:03 +01:00
uint8_t getRefModuleApid() const { return refApid; }
2022-11-08 11:08:21 +01:00
uint8_t getRefServiceId() const { return refServiceId; }
uint16_t getRefSequenceCount() const { return refSeqCount; }
uint32_t getStatusCode() const { return statusCode; }
2023-11-15 11:31:57 +01:00
virtual void printStatusInformation(const char* prefix) const {
2022-11-11 11:06:08 +01:00
bool codeHandled = true;
if (statusCode < 0x100) {
GeneralStatusCode code = static_cast<GeneralStatusCode>(getStatusCode());
switch (code) {
case GeneralStatusCode::OK: {
sif::warning << prefix << "Ok" << std::endl;
break;
}
case GeneralStatusCode::INIT_ERROR: {
sif::warning << prefix << "Init error" << std::endl;
break;
}
case GeneralStatusCode::BAD_PARAM: {
sif::warning << prefix << "Bad param" << std::endl;
break;
}
case GeneralStatusCode::NOT_INITIALIZED: {
sif::warning << prefix << "Not initialized" << std::endl;
break;
}
case GeneralStatusCode::BAD_PERIPH_ID: {
sif::warning << prefix << "Bad periph ID" << std::endl;
break;
}
case GeneralStatusCode::TIMEOUT: {
sif::warning << prefix << "Timeout" << std::endl;
break;
}
case GeneralStatusCode::RX_ERROR: {
sif::warning << prefix << "RX error" << std::endl;
break;
}
case GeneralStatusCode::TX_ERROR: {
sif::warning << prefix << "TX error" << std::endl;
break;
}
case GeneralStatusCode::BUF_EMPTY: {
sif::warning << prefix << "Buf empty" << std::endl;
break;
}
case GeneralStatusCode::NAK: {
sif::warning << prefix << "Nak, default error code" << std::endl;
break;
}
case GeneralStatusCode::ARB_LOST: {
sif::warning << prefix << "Arb lost" << std::endl;
break;
}
case GeneralStatusCode::BUSY: {
sif::warning << prefix << "Busy" << std::endl;
break;
}
case GeneralStatusCode::NOT_IMPL: {
sif::warning << prefix << "Not implemented" << std::endl;
break;
}
case GeneralStatusCode::ALIGNMENT_ERROR: {
sif::warning << prefix << "Alignment error" << std::endl;
break;
}
case GeneralStatusCode::PERIPH_ERROR: {
sif::warning << prefix << "Periph error" << std::endl;
break;
}
case GeneralStatusCode::FAILED_LATCH: {
sif::warning << prefix << "Failed latch" << std::endl;
break;
}
case GeneralStatusCode::GPIO_HIGH: {
sif::warning << prefix << "GPIO high" << std::endl;
break;
}
case GeneralStatusCode::GPIO_LOW: {
sif::warning << prefix << "GPIO low" << std::endl;
break;
}
case GeneralStatusCode::TEST_PASSED: {
sif::warning << prefix << "Test passed" << std::endl;
break;
}
case GeneralStatusCode::TEST_FAILED: {
sif::warning << prefix << "Test failed" << std::endl;
break;
}
default: {
codeHandled = false;
break;
}
}
2022-11-17 13:24:39 +01:00
} else if (statusCode < 0x200 and statusCode >= 0x100) {
2022-11-11 11:06:08 +01:00
BootManStatusCode code = static_cast<BootManStatusCode>(statusCode);
switch (code) {
case BootManStatusCode::NOTHING_TODO: {
sif::warning << prefix << "Nothing to do" << std::endl;
break;
}
case BootManStatusCode::POWER_FAULT: {
sif::warning << prefix << "Power fault" << std::endl;
break;
}
case BootManStatusCode::INVALID_LENGTH: {
sif::warning << prefix << "Invalid length" << std::endl;
break;
}
case BootManStatusCode::OUT_OF_RANGE: {
sif::warning << prefix << "Out of range, lenght check of parameter failed" << std::endl;
break;
}
case BootManStatusCode::OUT_OF_HEAP_MEMORY: {
sif::warning << prefix << "Out of heap memory" << std::endl;
break;
}
case BootManStatusCode::INVALID_STATE_TRANSITION: {
sif::warning << prefix << "Invalid state transition" << std::endl;
break;
}
case BootManStatusCode::MPSOC_ALREADY_BOOTING: {
sif::warning << prefix << "MPSoC already booting" << std::endl;
break;
}
case BootManStatusCode::MPSOC_ALREADY_OPERATIONAL: {
sif::warning << prefix << "MPSoC already operational" << std::endl;
break;
}
case BootManStatusCode::MPSOC_BOOT_FAILED: {
sif::warning << prefix << "MPSoC boot failed" << std::endl;
break;
}
default: {
2022-11-17 13:39:59 +01:00
codeHandled = false;
2022-11-11 11:06:08 +01:00
break;
}
}
2022-11-17 13:24:39 +01:00
} else if (statusCode < 0x300 and statusCode >= 0x200) {
2022-11-11 11:06:08 +01:00
MemManStatusCode code = static_cast<MemManStatusCode>(statusCode);
switch (code) {
case MemManStatusCode::SP_NOT_AVAILABLE: {
sif::warning << prefix << "SP not available" << std::endl;
break;
}
case MemManStatusCode::SP_DATA_INSUFFICIENT: {
sif::warning << prefix << "SP data insufficient" << std::endl;
break;
}
case MemManStatusCode::SP_MEMORY_ID_INVALID: {
sif::warning << prefix << "SP data insufficient" << std::endl;
break;
}
case MemManStatusCode::MPSOC_NOT_IN_RESET: {
sif::warning << prefix << "MPSoC not in reset" << std::endl;
break;
}
case MemManStatusCode::FLASH_INIT_FAILED: {
sif::warning << prefix << "Flash init failed" << std::endl;
break;
}
case MemManStatusCode::FLASH_ERASE_FAILED: {
sif::warning << prefix << "Flash erase failed" << std::endl;
break;
}
case MemManStatusCode::FLASH_WRITE_FAILED: {
sif::warning << prefix << "Flash write failed" << std::endl;
break;
}
case MemManStatusCode::FLASH_VERIFY_FAILED: {
sif::warning << prefix << "Flash verify failed" << std::endl;
break;
}
case MemManStatusCode::CANNOT_ACCESS_TM: {
sif::warning << prefix << "Can not access tm" << std::endl;
break;
}
case MemManStatusCode::CANNOT_SEND_TM: {
sif::warning << prefix << "Can not access tm" << std::endl;
break;
}
default: {
2022-11-17 13:39:59 +01:00
codeHandled = false;
2022-11-11 11:06:08 +01:00
break;
}
}
2022-11-17 13:24:39 +01:00
} else if (statusCode < 0x400 and statusCode >= 0x300) {
2022-11-11 11:06:08 +01:00
PowerManStatusCode code = static_cast<PowerManStatusCode>(statusCode);
switch (code) {
case PowerManStatusCode::PG_LOW: {
sif::warning << prefix << "PG low" << std::endl;
break;
}
case PowerManStatusCode::PG_5V_LOW: {
sif::warning << prefix << "PG 5V low" << std::endl;
break;
}
case PowerManStatusCode::PG_0V85_LOW: {
sif::warning << prefix << "PG 0V85 low" << std::endl;
break;
}
case PowerManStatusCode::PG_1V8_LOW: {
sif::warning << prefix << "PG 1V8 low" << std::endl;
break;
}
case PowerManStatusCode::PG_MISC_LOW: {
sif::warning << prefix << "PG misc low" << std::endl;
break;
}
case PowerManStatusCode::PG_3V3_LOW: {
sif::warning << prefix << "PG 3V3 low" << std::endl;
break;
}
case PowerManStatusCode::PG_MB_VAIO_LOW: {
sif::warning << prefix << "PG mb vaio low" << std::endl;
break;
}
case PowerManStatusCode::PG_MB_MPSOCIO_LOW: {
sif::warning << prefix << "PG mb mpsocio low" << std::endl;
break;
}
default: {
2022-11-17 13:39:59 +01:00
codeHandled = false;
break;
}
}
} else if (statusCode >= 0x600) {
TmtcManStatusCode code = static_cast<TmtcManStatusCode>(statusCode);
switch (code) {
case TmtcManStatusCode::BUF_FULL: {
sif::warning << prefix << "TMTC MAN: Buffer full" << std::endl;
break;
}
case TmtcManStatusCode::WRONG_APID: {
sif::warning << prefix << "TMTC MAN: Wrong APID" << std::endl;
break;
}
case TmtcManStatusCode::WRONG_SERVICE_ID: {
sif::warning << prefix << "TMTC MAN: Wrong Service ID" << std::endl;
break;
}
case TmtcManStatusCode::TC_DELIVERY_ACCEPTED: {
sif::warning << prefix << "TMTC MAN: TC accepted" << std::endl;
break;
}
case TmtcManStatusCode::TC_DELIVERY_REJECTED: {
sif::warning << prefix << "TMTC MAN: TC rejected" << std::endl;
break;
}
case TmtcManStatusCode::TC_PACKET_LEN_INCORRECT: {
sif::warning << prefix << "TMTC MAN: TC packet lenght incorrect" << std::endl;
break;
}
case TmtcManStatusCode::BAD_CRC: {
sif::warning << prefix << "TMTC MAN: Bad CRC" << std::endl;
break;
}
case TmtcManStatusCode::BAD_DEST: {
sif::warning << prefix << "TMTC MAN: Bad destination" << std::endl;
break;
}
case TmtcManStatusCode::BAD_SP_HEADER: {
sif::warning << prefix << "TMTC MAN: Bad SP header" << std::endl;
break;
}
default: {
codeHandled = false;
2022-11-11 11:06:08 +01:00
break;
}
}
}
if (not codeHandled) {
sif::warning << prefix << "Invalid or unimplemented status code: 0x" << std::hex
<< std::setfill('0') << std::setw(4) << static_cast<uint16_t>(statusCode)
<< std::dec << std::endl;
}
}
protected:
2022-11-08 11:08:21 +01:00
TmBase& readerBase;
uint8_t refApid = 0;
uint8_t refServiceId = 0;
uint16_t refSeqCount = 0;
uint32_t statusCode = 0;
static const size_t PAYLOAD_LEN = 8;
};
class AcknowledgmentReport : public VerificationReport {
public:
2022-11-08 11:08:21 +01:00
AcknowledgmentReport(TmBase& readerBase) : VerificationReport(readerBase) {}
2023-11-15 11:31:57 +01:00
ReturnValue_t parse(bool checkCrc) override {
2022-11-08 16:26:30 +01:00
if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::ACK) and
readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::NAK)) {
2022-11-08 17:07:12 +01:00
return result::INVALID_SERVICE_ID;
2022-11-08 16:26:30 +01:00
}
2023-11-15 11:31:57 +01:00
return VerificationReport::parse(checkCrc);
}
2023-11-15 11:31:57 +01:00
void printStatusInformationAck() {
2022-11-11 11:06:08 +01:00
VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX);
}
private:
2022-11-11 11:06:08 +01:00
static constexpr char STATUS_PRINTOUT_PREFIX[] = "SUPV NAK Status: ";
};
class ExecutionReport : public VerificationReport {
public:
2022-11-08 11:08:21 +01:00
ExecutionReport(TmBase& readerBase) : VerificationReport(readerBase) {}
2022-11-08 20:04:57 +01:00
TmBase& getReader() { return readerBase; }
2023-11-15 11:31:57 +01:00
ReturnValue_t parse(bool checkCrc) override {
2022-11-08 16:26:30 +01:00
if (readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_ACK) and
readerBase.getServiceId() != static_cast<uint8_t>(tm::TmtcId::EXEC_NAK)) {
return returnvalue::FAILED;
}
2023-11-15 11:31:57 +01:00
return VerificationReport::parse(checkCrc);
}
2022-11-11 11:06:08 +01:00
2023-11-15 11:31:57 +01:00
void printStatusInformationExe() {
2022-11-11 11:06:08 +01:00
VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX);
2022-04-29 23:22:44 +02:00
}
2022-11-08 16:26:30 +01:00
private:
2022-11-11 11:06:08 +01:00
static constexpr char STATUS_PRINTOUT_PREFIX[] = "SUPV EXE NAK Status: ";
};
2022-11-08 16:56:42 +01:00
class UpdateStatusReport {
public:
UpdateStatusReport(TmBase& tmReader) : tmReader(tmReader) {}
2023-11-15 11:31:57 +01:00
ReturnValue_t parse(bool checkCrc) {
if (checkCrc and tmReader.checkCrc() != returnvalue::OK) {
2022-11-08 16:56:42 +01:00
return result::CRC_FAILURE;
}
2022-11-21 18:32:23 +01:00
if (tmReader.getModuleApid() != Apid::MEM_MAN) {
2022-11-08 16:56:42 +01:00
return result::INVALID_APID;
}
if (tmReader.getBufSize() < MIN_TMTC_LEN + PAYLOAD_LEN or
tmReader.getPayloadLen() < PAYLOAD_LEN) {
sif::error << "VerificationReport: Invalid verification report, payload too small"
<< std::endl;
return result::BUF_TOO_SMALL;
}
2022-11-21 18:32:23 +01:00
size_t remLen = tmReader.getPayloadLen();
2022-11-08 16:56:42 +01:00
const uint8_t* dataFieldPtr = tmReader.getPayloadStart();
SerializeAdapter::deSerialize(&memoryId, &dataFieldPtr, &remLen, SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&n, &dataFieldPtr, &remLen, SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&startAddress, &dataFieldPtr, &remLen,
SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&length, &dataFieldPtr, &remLen, SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&crc, &dataFieldPtr, &remLen, SerializeIF::Endianness::BIG);
return returnvalue::OK;
}
ReturnValue_t verifyCrc(uint16_t goodCrc) const {
if (crc != goodCrc) {
return result::UPDATE_CRC_FAILURE;
}
return returnvalue::OK;
}
uint16_t getCrc() const { return crc; }
private:
TmBase& tmReader;
// Nominal size of the space packet
static const uint16_t PAYLOAD_LEN = 12; // header, data field and crc
uint8_t memoryId = 0;
uint8_t n = 0;
uint32_t startAddress = 0;
uint32_t length = 0;
uint16_t crc = 0;
};
2022-04-10 18:46:39 +02:00
/**
* @brief This dataset stores the boot status report of the supervisor.
*/
class BootStatusReport : public StaticLocalDataSet<BOOT_REPORT_SET_ENTRIES> {
public:
BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {}
BootStatusReport(object_id_t objectId)
: StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {}
/** Information about boot status of MPSoC */
2022-04-11 16:52:50 +02:00
lp_var_t<uint8_t> socState = lp_var_t<uint8_t>(sid.objectId, PoolIds::BR_SOC_STATE, this);
lp_var_t<uint8_t> powerCycles = lp_var_t<uint8_t>(sid.objectId, PoolIds::POWER_CYCLES, this);
2022-04-10 18:46:39 +02:00
/** Time the MPSoC needs for last boot */
lp_var_t<uint32_t> bootAfterMs = lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_AFTER_MS, this);
/** The currently set boot timeout */
lp_var_t<uint32_t> bootTimeoutMs =
2023-11-09 17:19:28 +01:00
lp_var_t<uint32_t>(sid.objectId, PoolIds::BOOT_TIMEOUT_POOL_VAR_MS, this);
2022-04-10 18:46:39 +02:00
lp_var_t<uint8_t> activeNvm = lp_var_t<uint8_t>(sid.objectId, PoolIds::ACTIVE_NVM, this);
/** States of the boot partition pins */
lp_var_t<uint8_t> bp0State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP0_STATE, this);
lp_var_t<uint8_t> bp1State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP1_STATE, this);
lp_var_t<uint8_t> bp2State = lp_var_t<uint8_t>(sid.objectId, PoolIds::BP2_STATE, this);
lp_var_t<uint8_t> bootState = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_STATE, this);
lp_var_t<uint8_t> bootCycles = lp_var_t<uint8_t>(sid.objectId, PoolIds::BOOT_CYCLES, this);
};
/**
* @brief This dataset stores the housekeeping data of the supervisor.
*/
2022-01-17 15:58:27 +01:00
class HkSet : public StaticLocalDataSet<HK_SET_ENTRIES> {
public:
2022-05-05 19:18:39 +02:00
enum class SocState { OFF = 0, BOOTING = 1, OPERATIONAL = 3, SHUTDOWN = 4 };
2022-05-03 14:59:23 +02:00
2022-01-17 15:58:27 +01:00
HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {}
HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {}
lp_var_t<uint32_t> tempPs = lp_var_t<uint32_t>(sid.objectId, PoolIds::TEMP_PS, this);
lp_var_t<uint32_t> tempPl = lp_var_t<uint32_t>(sid.objectId, PoolIds::TEMP_PS, this);
lp_var_t<uint32_t> tempSup = lp_var_t<uint32_t>(sid.objectId, PoolIds::TEMP_SUP, this);
2022-04-06 07:10:20 +02:00
lp_var_t<uint64_t> uptime = lp_var_t<uint64_t>(sid.objectId, PoolIds::UPTIME, this);
2022-01-17 15:58:27 +01:00
lp_var_t<uint32_t> cpuLoad = lp_var_t<uint32_t>(sid.objectId, PoolIds::CPULOAD, this);
lp_var_t<uint32_t> availableHeap = lp_var_t<uint32_t>(sid.objectId, PoolIds::AVAILABLEHEAP, this);
lp_var_t<uint32_t> numTcs = lp_var_t<uint32_t>(sid.objectId, PoolIds::NUM_TCS, this);
lp_var_t<uint32_t> numTms = lp_var_t<uint32_t>(sid.objectId, PoolIds::NUM_TMS, this);
2022-04-11 16:52:50 +02:00
lp_var_t<uint32_t> socState = lp_var_t<uint32_t>(sid.objectId, PoolIds::HK_SOC_STATE, this);
2022-01-17 15:58:27 +01:00
lp_var_t<uint8_t> nvm0_1_state = lp_var_t<uint8_t>(sid.objectId, PoolIds::NVM0_1_STATE, this);
lp_var_t<uint8_t> nvm3_state = lp_var_t<uint8_t>(sid.objectId, PoolIds::NVM3_STATE, this);
lp_var_t<uint8_t> missionIoState =
lp_var_t<uint8_t>(sid.objectId, PoolIds::MISSION_IO_STATE, this);
lp_var_t<uint8_t> fmcState = lp_var_t<uint8_t>(sid.objectId, PoolIds::FMC_STATE, this);
};
/**
* @brief This dataset stores the last requested latchup status report.
*/
2022-01-17 15:58:27 +01:00
class LatchupStatusReport : public StaticLocalDataSet<LATCHUP_RPT_SET_ENTRIES> {
public:
LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {}
LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {}
lp_var_t<uint8_t> id = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_ID, this);
lp_var_t<uint16_t> cnt0 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT0, this);
lp_var_t<uint16_t> cnt1 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT1, this);
lp_var_t<uint16_t> cnt2 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT2, this);
lp_var_t<uint16_t> cnt3 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT3, this);
lp_var_t<uint16_t> cnt4 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT4, this);
lp_var_t<uint16_t> cnt5 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT5, this);
lp_var_t<uint16_t> cnt6 = lp_var_t<uint16_t>(sid.objectId, PoolIds::CNT6, this);
2022-04-06 07:10:20 +02:00
lp_var_t<uint16_t> timeMsec =
lp_var_t<uint16_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this);
lp_var_t<uint8_t> timeSec = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this);
lp_var_t<uint8_t> timeMin = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this);
lp_var_t<uint8_t> timeHour =
lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this);
lp_var_t<uint8_t> timeDay = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this);
lp_var_t<uint8_t> timeMon = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this);
lp_var_t<uint8_t> timeYear =
lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this);
2022-04-11 16:52:50 +02:00
lp_var_t<uint8_t> isSet = lp_var_t<uint8_t>(sid.objectId, PoolIds::LATCHUP_RPT_IS_SET, this);
2022-04-06 08:36:34 +02:00
2022-04-11 16:52:50 +02:00
static const uint8_t IS_SET_BIT_POS = 15;
2022-04-10 18:46:39 +02:00
};
2022-04-13 11:56:37 +02:00
/**
* @brief This dataset stores the logging report.
*/
2023-11-08 10:46:59 +01:00
class CountersReport : public StaticLocalDataSet<LOGGING_RPT_SET_ENTRIES> {
2022-04-13 11:56:37 +02:00
public:
2023-11-08 10:46:59 +01:00
CountersReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LOGGING_RPT_ID) {}
CountersReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LOGGING_RPT_ID)) {}
lp_var_t<uint32_t> signature =
lp_var_t<uint32_t>(sid.objectId, PoolIds::LATCHUP_HAPPENED_CNTS, this);
lp_vec_t<uint32_t, 7> latchupHappenCnts =
lp_vec_t<uint32_t, 7>(sid.objectId, PoolIds::LATCHUP_HAPPENED_CNTS, this);
2022-04-22 08:55:57 +02:00
lp_var_t<uint32_t> adcDeviationTriggersCnt =
lp_var_t<uint32_t>(sid.objectId, PoolIds::ADC_DEVIATION_TRIGGERS_CNT, this);
lp_var_t<uint32_t> tcReceivedCnt =
lp_var_t<uint32_t>(sid.objectId, PoolIds::TC_RECEIVED_CNT, this);
lp_var_t<uint32_t> tmAvailableCnt =
lp_var_t<uint32_t>(sid.objectId, PoolIds::TM_AVAILABLE_CNT, this);
lp_var_t<uint32_t> supervisorBoots =
lp_var_t<uint32_t>(sid.objectId, PoolIds::SUPERVISOR_BOOTS, this);
lp_var_t<uint32_t> mpsocBoots = lp_var_t<uint32_t>(sid.objectId, PoolIds::MPSOC_BOOTS, this);
2022-04-22 08:55:57 +02:00
lp_var_t<uint32_t> mpsocBootFailedAttempts =
lp_var_t<uint32_t>(sid.objectId, PoolIds::MPSOC_BOOT_FAILED_ATTEMPTS, this);
lp_var_t<uint32_t> mpsocPowerup = lp_var_t<uint32_t>(sid.objectId, PoolIds::MPSOC_POWER_UP, this);
lp_var_t<uint32_t> mpsocUpdates = lp_var_t<uint32_t>(sid.objectId, PoolIds::MPSOC_UPDATES, this);
2023-11-08 10:46:59 +01:00
lp_var_t<uint32_t> mpsocHeartbeatResets =
lp_var_t<uint32_t>(sid.objectId, PoolIds::MPSOC_HEARTBEAT_RESETS, this);
lp_var_t<uint32_t> cpuWdtResets =
lp_var_t<uint32_t>(sid.objectId, PoolIds::MPSOC_HEARTBEAT_RESETS, this);
lp_var_t<uint32_t> psHeartbeatsLost =
lp_var_t<uint32_t>(sid.objectId, PoolIds::PS_HEARTBEATS_LOST, this);
lp_var_t<uint32_t> plHeartbeatsLost =
lp_var_t<uint32_t>(sid.objectId, PoolIds::PL_HEARTBEATS_LOST, this);
lp_var_t<uint32_t> ebTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::EB_TASK_LOST, this);
lp_var_t<uint32_t> bmTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::BM_TASK_LOST, this);
lp_var_t<uint32_t> lmTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::LM_TASK_LOST, this);
lp_var_t<uint32_t> amTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::AM_TASK_LOST, this);
lp_var_t<uint32_t> tctmmTaskLost =
lp_var_t<uint32_t>(sid.objectId, PoolIds::TCTMM_TASK_LOST, this);
lp_var_t<uint32_t> mmTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::MM_TASK_LOST, this);
lp_var_t<uint32_t> hkTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::HK_TASK_LOST, this);
lp_var_t<uint32_t> dlTaskLost = lp_var_t<uint32_t>(sid.objectId, PoolIds::DL_TASK_LOST, this);
lp_vec_t<uint32_t, 3> rwsTasksLost =
lp_vec_t<uint32_t, 3>(sid.objectId, PoolIds::RWS_TASKS_LOST, this);
2022-04-13 11:56:37 +02:00
void printSet() {
2023-11-08 10:46:59 +01:00
for (unsigned i = 0; i < 7; i++) {
sif::info << "LoggingReport: Latchup happened count " << i << ": "
<< this->latchupHappenCnts[i] << std::endl;
}
sif::info << "LoggingReport: ADC deviation triggers count: " << this->adcDeviationTriggersCnt
<< std::endl;
2022-04-22 08:55:57 +02:00
sif::info << "LoggingReport: TC received count: " << this->tcReceivedCnt << std::endl;
sif::info << "LoggingReport: TM available count: " << this->tmAvailableCnt << std::endl;
sif::info << "LoggingReport: Supervisor boots: " << this->supervisorBoots << std::endl;
sif::info << "LoggingReport: MPSoC boots: " << this->mpsocBoots << std::endl;
sif::info << "LoggingReport: MPSoC boot failed attempts: " << this->mpsocBootFailedAttempts
<< std::endl;
2022-04-22 08:55:57 +02:00
sif::info << "LoggingReport: MPSoC power up: " << this->mpsocPowerup << std::endl;
sif::info << "LoggingReport: MPSoC updates: " << this->mpsocUpdates << std::endl;
2022-04-13 11:56:37 +02:00
}
};
2022-04-21 16:30:23 +02:00
/**
* @brief This dataset stores the ADC report.
*/
2023-11-08 10:46:59 +01:00
class AdcReport : public StaticLocalDataSet<3> {
2022-04-21 16:30:23 +02:00
public:
AdcReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ADC_REPORT_SET_ID) {}
AdcReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ADC_REPORT_SET_ID)) {}
2023-11-08 10:46:59 +01:00
lp_vec_t<uint16_t, 16> adcRaw = lp_vec_t<uint16_t, 16>(sid.objectId, PoolIds::ADC_RAW, this);
lp_vec_t<uint16_t, 16> adcEng = lp_vec_t<uint16_t, 16>(sid.objectId, PoolIds::ADC_ENG, this);
2022-04-21 16:30:23 +02:00
void printSet() {
sif::info << "---- Adc Report: Raw values ----" << std::endl;
2023-11-08 10:46:59 +01:00
for (unsigned i = 0; i < 16; i++) {
sif::info << "AdcReport: ADC raw " << i << ": " << std::dec << this->adcRaw[i] << std::endl;
}
for (unsigned i = 0; i < 16; i++) {
sif::info << "AdcReport: ADC eng " << i << ": " << std::dec << this->adcEng[i] << std::endl;
}
2022-04-21 16:30:23 +02:00
}
};
namespace notimpl {
/**
* @brief This class packages the space packet to perform the factory reset. The op parameter is
* optional.
*
* @details: Without OP: All MRAM entries will be cleared.
* OP = 0x01: Only the mirror entries will be wiped.
* OP = 0x02: Only the circular entries will be wiped.
*/
class FactoryReset : public TcBase {
public:
enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES };
/**
* @brief Constructor
*
* @param op
*/
2022-11-08 14:26:52 +01:00
FactoryReset(TcParams params) : TcBase(params, Apid::TMTC_MAN, 0x11, 1) {}
ReturnValue_t buildPacket(Op op) {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
initPacket(op);
return calcAndSetCrc();
}
private:
void initPacket(Op op) {
size_t packetDataLen = 2;
switch (op) {
case Op::MIRROR_ENTRIES:
payloadStart[0] = 1;
packetDataLen = 3;
break;
case Op::CIRCULAR_ENTRIES:
payloadStart[0] = 2;
packetDataLen = 3;
break;
default:
break;
}
spParams.setFullPayloadLen(packetDataLen);
}
};
/**
* @brief This class creates the command to enable or disable the NVMs connected to the
* supervisor.
*/
class EnableNvms : public TcBase {
public:
/**
* @brief Constructor
*
* @param mem The memory to boot from: NVM0 (0), NVM1 (1)
* @param bp0 Partition pin 0
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
*/
2022-11-08 14:26:52 +01:00
EnableNvms(TcParams params) : TcBase(params, Apid::TMTC_MAN, 0x06, 2) {}
ReturnValue_t buildPacket(uint8_t nvm01, uint8_t nvm3) {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
initPacket(nvm01, nvm3);
return calcAndSetCrc();
}
private:
void initPacket(uint8_t nvm01, uint8_t nvm3) {
payloadStart[0] = nvm01;
payloadStart[1] = nvm3;
}
};
/**
* @brief This class creates the space packet to enable the auto TM generation
*/
class EnableAutoTm : public TcBase {
public:
2023-11-08 10:46:59 +01:00
EnableAutoTm(TcParams params) : TcBase(params) { spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2); }
ReturnValue_t buildPacket() {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
payloadStart[0] = ENABLE;
return calcAndSetCrc();
}
private:
static const uint16_t PAYLOAD_LENGTH = 1; // length without CRC field
static const uint8_t ENABLE = 1;
};
/**
* @brief This class creates the space packet to disable the auto TM generation
*/
class DisableAutoTm : public TcBase {
public:
DisableAutoTm(TcParams params) : TcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
// spParams.creator.setApid(APID_AUTO_TM);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
ReturnValue_t buildPacket() {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
payloadStart[0] = DISABLE;
return calcAndSetCrc();
}
private:
static const uint16_t PAYLOAD_LENGTH = 1; // length without CRC field
static const uint8_t DISABLE = 0;
};
/**
* @brief This class creates the space packet to request the logging data from the supervisor
*/
class RequestLoggingData : public TcBase {
public:
/**
* Subapid
*/
enum class Sa : uint8_t {
REQUEST_COUNTERS = 1, /**< REQUEST_COUNTERS */
REQUEST_EVENT_BUFFERS = 2, /**< REQUEST_EVENT_BUFFERS */
CLEAR_COUNTERS = 3, /**< CLEAR_COUNTERS */
SET_LOGGING_TOPIC = 4 /**< SET_LOGGING_TOPIC */
};
RequestLoggingData(TcParams params) : TcBase(params) {
spParams.setFullPayloadLen(PAYLOAD_LENGTH + 2);
// spParams.creator.setApid(APID_REQUEST_LOGGING_DATA);
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
/**
* @param sa
* @param tpc Topic
* @return
*/
ReturnValue_t buildPacket(Sa sa, uint8_t tpc = 0) {
auto res = checkSizeAndSerializeHeader();
if (res != returnvalue::OK) {
return res;
}
payloadStart[0] = static_cast<uint8_t>(sa);
payloadStart[1] = tpc;
return calcAndSetCrc();
}
private:
static const uint16_t PAYLOAD_LENGTH = 2; // length without CRC field
static const uint8_t TPC_OFFSET = 1;
};
typedef struct {
// The most significant bit of msec value is set to 0x80 to indicate that full
// time and data information is transmitted, when the time has been synced with
// the reference. If the time has not been synced with reference, then the most
// significant bit is set to 0x00. Only the most significant bit is used for
// this purpose (bit 15 of the field tm_msec)
uint16_t tm_msec; // miliseconds 0-999;
uint8_t tm_sec; // seconds after the minute, 0 to 60
// (0 - 60 allows for the occasional leap second)
uint8_t tm_min; // minutes after the hour, 0 to 59
uint8_t tm_hour; // hours since midnight, 0 to 23
uint8_t tm_mday; // day of the month, 1 to 31
uint8_t tm_mon; // months 1 to 12
uint8_t tm_year; // years since 1900
} tas_time_t;
} // namespace notimpl
2022-04-04 13:40:45 +02:00
} // namespace supv
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */