#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ #include #include #include #include #include #include #include #include #include #include "eive/eventSubsystemIds.h" #include "eive/resultClassIds.h" namespace supv { static constexpr bool DEBUG_PLOC_SUPV = false; static constexpr bool REDUCE_NORMAL_MODE_PRINTOUT = true; 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); //! [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); extern std::atomic_bool SUPV_ON; static constexpr uint32_t INTER_COMMAND_DELAY = 20; static constexpr uint32_t BOOT_TIMEOUT_MS = 4000; static constexpr uint32_t MAX_TRANSITION_TIME_TO_ON_MS = BOOT_TIMEOUT_MS + 3000; 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); static constexpr ReturnValue_t INVALID_SERVICE_ID = MAKE_RETURN_CODE(0xA1); //! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA2); //! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA3); //! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA4); //! [EXPORT] : [COMMENT] Failed to read current system time 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 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. static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA7); //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID 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. 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. static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xAA); //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. 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) 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. static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAD); //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist 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. 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 static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB1); //! [EXPORT] : [COMMENT] Filename too long static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xB2); //! [EXPORT] : [COMMENT] Received update status report with invalid packet length field 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. 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) static const ReturnValue_t SUPV_HELPER_EXECUTING = MAKE_RETURN_CODE(0xB5); static constexpr ReturnValue_t BUF_TOO_SMALL = MAKE_RETURN_CODE(0xC0); static constexpr ReturnValue_t NO_REPLY_TIMEOUT = MAKE_RETURN_CODE(0xC1); }; // namespace result 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; static const DeviceCommandId_t DISABLE_PERIOIC_HK_TRANSMISSION = 10; 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; 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; static const DeviceCommandId_t REQUEST_LOGGING_COUNTERS = 38; static constexpr DeviceCommandId_t FACTORY_RESET = 39; static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43; static const DeviceCommandId_t START_MPSOC_QUIET = 45; static const DeviceCommandId_t SET_SHUTDOWN_TIMEOUT = 46; static const DeviceCommandId_t FACTORY_FLASH = 47; static const DeviceCommandId_t PERFORM_UPDATE = 48; static const DeviceCommandId_t TERMINATE_SUPV_HELPER = 49; static const DeviceCommandId_t ENABLE_AUTO_TM = 50; static const DeviceCommandId_t DISABLE_AUTO_TM = 51; 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; static constexpr DeviceCommandId_t REQUEST_ADC_REPORT = 57; static const DeviceCommandId_t RESET_PL = 58; static const DeviceCommandId_t ENABLE_NVMS = 59; static const DeviceCommandId_t CONTINUE_UPDATE = 60; static const DeviceCommandId_t MEMORY_CHECK_WITH_FILE = 61; static constexpr DeviceCommandId_t MEMORY_CHECK = 62; static constexpr DeviceCommandId_t ABORT_LONGER_REQUEST = 63; /** Reply IDs */ enum ReplyId : DeviceCommandId_t { ACK_REPORT = 100, EXE_REPORT = 101, HK_REPORT = 102, BOOT_STATUS_REPORT = 103, LATCHUP_REPORT = 104, COUNTERS_REPORT = 105, ADC_REPORT = 106, UPDATE_STATUS_REPORT = 107, }; // 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; static const uint16_t SIZE_BOOT_STATUS_REPORT = 24; static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 31; static const uint16_t SIZE_COUNTERS_REPORT = 120; static const uint16_t SIZE_ADC_REPORT = 72; // 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; enum Apid { TMTC_MAN = 0x00, HK = 0x01, BOOT_MAN = 0x02, LATCHUP_MON = 0x03, ADC_MON = 0x04, MEM_MAN = 0x05, DATA_LOGGER = 0x06, WDOG_MAN = 0x07 }; namespace tc { enum class HkId : uint8_t { ENABLE = 0x01, SET_PERIOD = 0x02, GET_REPORT = 0x03, GET_HARDFAULTS_REPORT = 0x04, }; 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 }; enum class BootManId : uint8_t { 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 }; enum class LatchupMonId : uint8_t { 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 enum class AdcMonId : uint8_t { SET_SWEEP_PERIOD = 0x01, SET_ENABLED_CHANNELS = 0x02, SET_WINDOW_STRIDE = 0x03, SET_ADC_THRESHOLD = 0x04, COPY_ADC_DATA_TO_MRAM = 0x05, REQUEST_ADC_SAMPLE = 0x06 }; enum class MemManId : uint8_t { ERASE = 0x01, WRITE = 0x02, CHECK = 0x03 }; enum class DataLoggerServiceId : uint8_t { // Not implemented. READ_MRAM_CFG_DATA_LOGGER = 0x00, REQUEST_COUNTERS = 0x01, // Not implemented. EVENT_BUFFER_DOWNLOAD = 0x02, WIPE_MRAM = 0x05, DUMP_MRAM = 0x06, FACTORY_RESET = 0x07 }; // Right now, none of the commands seem to be implemented, but still // keep the enum here in case some are added 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 }; enum class AdcMonId : uint8_t { ADC_REPORT = 0x01 }; enum class MemManId : uint8_t { UPDATE_STATUS_REPORT = 0x01 }; enum class LatchupMonId : uint8_t { LATCHUP_STATUS_REPORT = 0x01 }; enum class DataLoggerId : uint8_t { COUNTERS_REPORT = 0x01 }; } // namespace tm 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 }; static constexpr uint16_t APID_MASK_TC = 0x80; static constexpr uint16_t APID_MASK_TM = 0x200; static constexpr uint16_t APID_MODULE_MASK = 0x7F; static const uint16_t SEQUENCE_COUNT_MASK = 0xFFF; 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; static const uint8_t LOGGING_RPT_SET_ENTRIES = 30; static const uint8_t ADC_RPT_SET_ENTRIES = 32; 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; static const uint32_t LOGGING_RPT_ID = COUNTERS_REPORT; static const uint32_t ADC_REPORT_SET_ID = ADC_REPORT; namespace timeout { // 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; static const uint32_t CRC_EXECUTION_TIMEOUT = 60000; } // namespace timeout 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; 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; static constexpr size_t MIN_PAYLOAD_LEN = SECONDARY_HEADER_LEN + CRC_LEN; static constexpr size_t MIN_TMTC_LEN = ccsds::HEADER_LEN + MIN_PAYLOAD_LEN; static constexpr size_t PAYLOAD_OFFSET = ccsds::HEADER_LEN + SECONDARY_HEADER_LEN; 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 }; struct UpdateParams { std::string file; uint8_t memId; uint32_t startAddr; uint32_t bytesWritten; uint16_t seqCount; bool deleteMemory; }; enum PoolIds : lp_id_t { NUM_TMS, TEMP_PS, TEMP_PL, HK_SOC_STATE, NVM0_1_STATE, NVM3_STATE, MISSION_IO_STATE, FMC_STATE, NUM_TCS, TEMP_SUP, UPTIME, CPULOAD, AVAILABLEHEAP, BR_SOC_STATE, POWER_CYCLES, BOOT_AFTER_MS, BOOT_TIMEOUT_POOL_VAR_MS, ACTIVE_NVM, BP0_STATE, BP1_STATE, BP2_STATE, BOOT_STATE, BOOT_CYCLES, 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, LATCHUP_RPT_IS_SET, SIGNATURE, LATCHUP_HAPPENED_CNTS, ADC_DEVIATION_TRIGGERS_CNT, TC_RECEIVED_CNT, TM_AVAILABLE_CNT, SUPERVISOR_BOOTS, MPSOC_BOOTS, MPSOC_BOOT_FAILED_ATTEMPTS, MPSOC_POWER_UP, MPSOC_UPDATES, 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, }; struct TcParams : public ploc::SpTcParams { public: TcParams(SpacePacketCreator& creator) : ploc::SpTcParams(creator) {} TcParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize) : ploc::SpTcParams(creator, buf, maxSize) {} void setLenFromPayloadLen(size_t payloadLen) { setFullPayloadLen(ccsds::HEADER_LEN + SECONDARY_HEADER_LEN + payloadLen + CRC_LEN); } }; class TcBase : public ploc::SpTcBase { public: 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) {} TcBase(TcParams params, uint16_t apid, uint8_t serviceId, size_t payloadLen, uint16_t seqCount) : ploc::SpTcBase(params, apid | APID_MASK_TC, fullSpDataLenFromPayloadLen(payloadLen), seqCount) { setup(serviceId); } void setServiceId(uint8_t id) { if (spParams.maxSize < MIN_PAYLOAD_LEN) { return; } payloadStart[supv::PAYLOAD_OFFSET] = id; } uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; } uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; } static size_t fullSpDataLenFromPayloadLen(size_t payloadLen) { return SECONDARY_HEADER_LEN + payloadLen + CRC_LEN; } void setLenFromPayloadLen(size_t payloadLen) { spParams.setFullPayloadLen(fullSpDataLenFromPayloadLen(payloadLen)); updateLenFromParams(); } private: ReturnValue_t setup(uint8_t serviceId) { 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); payloadStart = spParams.buf + ccsds::HEADER_LEN + SECONDARY_HEADER_LEN; spParams.buf[ccsds::HEADER_LEN + SECONDARY_HEADER_LEN - 1] = serviceId; spParams.creator.setSecHeaderFlag(); return returnvalue::OK; } }; class TmBase : public ploc::SpTmReader { public: TmBase() = default; TmBase(const uint8_t* data, size_t maxSize) : ploc::SpTmReader(data, maxSize) { if (maxSize < MIN_TMTC_LEN) { sif::error << "SupvTcBase::SupvTcBase: Passed buffer is too small" << std::endl; } } uint8_t getServiceId() const { return getPacketData()[TIMESTAMP_LEN]; } uint16_t getModuleApid() const { return getApid() & APID_MODULE_MASK; } const uint8_t* getPayloadStart() const { return getPacketData() + SECONDARY_HEADER_LEN; } size_t getPayloadLen() const { if (getFullPacketLen() > SECONDARY_HEADER_LEN + ccsds::HEADER_LEN) { return getFullPacketLen() - SECONDARY_HEADER_LEN - ccsds::HEADER_LEN; } return 0; } }; class NoPayloadPacket : public TcBase { public: NoPayloadPacket(TcParams params, uint16_t apid, uint8_t serviceId) : NoPayloadPacket(params, apid, serviceId, 0) {} NoPayloadPacket(TcParams params, uint16_t apid, uint8_t serviceId, uint16_t seqId) : TcBase(params, apid, serviceId, MIN_PAYLOAD_LEN, seqId) {} ReturnValue_t buildPacket() { ReturnValue_t result = checkSizeAndSerializeHeader(); if (result != returnvalue::OK) { return result; } return calcAndSetCrc(); } private: }; /** * @brief This class can be used to generate the space packet selecting the boot image of * of the MPSoC. */ class MPSoCBootSelect : public TcBase { public: static const uint8_t NVM0 = 0; static const uint8_t NVM1 = 1; /** * @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 * * @note Selection of partitions is currently not supported. */ MPSoCBootSelect(TcParams params) : TcBase(params, Apid::BOOT_MAN, static_cast(tc::BootManId::SELECT_IMAGE), 4) {} ReturnValue_t buildPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(mem, bp0, bp1, bp2); return calcAndSetCrc(); } private: void initPacket(uint8_t mem = 0, uint8_t bp0 = 0, uint8_t bp1 = 0, uint8_t bp2 = 0) { payloadStart[0] = mem; payloadStart[1] = bp0; payloadStart[2] = bp1; payloadStart[3] = bp2; } }; /** * @brief This class generates the space packet to update the time of the PLOC supervisor. */ class SetTimeRef : public TcBase { public: static constexpr size_t PAYLOAD_LEN = 8; SetTimeRef(TcParams params) : TcBase(params, Apid::TMTC_MAN, static_cast(tc::TmtcId::TIME_REF), 8) {} ReturnValue_t buildPacket(Clock::TimeOfDay_t* time) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } res = initPacket(time); if (res != returnvalue::OK) { return res; } return calcAndSetCrc(); } private: static const uint16_t SYNC = 0x8000; ReturnValue_t initPacket(Clock::TimeOfDay_t* time) { size_t serializedSize = 6; uint8_t* dataFieldPtr = payloadStart; uint16_t milliseconds = static_cast(time->usecond / 1000) | SYNC; ReturnValue_t result = SerializeAdapter::serialize(&milliseconds, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { return result; } uint8_t second = static_cast(time->second); result = SerializeAdapter::serialize(&second, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { return result; } uint8_t minute = static_cast(time->minute); result = SerializeAdapter::serialize(&minute, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { return result; } uint8_t hour = static_cast(time->hour); result = SerializeAdapter::serialize(&hour, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { return result; } uint8_t day = static_cast(time->day); result = SerializeAdapter::serialize(&day, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { return result; } uint8_t month = static_cast(time->month); result = SerializeAdapter::serialize(&month, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { return result; } uint8_t year = static_cast(time->year - 1900); return SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); } }; /** * @brief This class can be used to generate the set boot timout command. */ class SetBootTimeout : public TcBase { public: static constexpr size_t PAYLOAD_LEN = 4; /** * @brief Constructor * * @param timeout The boot timeout in milliseconds. */ SetBootTimeout(TcParams params) : TcBase(params, Apid::BOOT_MAN, static_cast(tc::BootManId::SET_BOOT_TIMEOUT), PAYLOAD_LEN) {} ReturnValue_t buildPacket(uint32_t timeout) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(timeout); return calcAndSetCrc(); } private: void initPacket(uint32_t timeout) { size_t serializedSize = 0; uint8_t* dataFieldPtr = payloadStart; SerializeAdapter::serialize(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout), SerializeIF::Endianness::BIG); } }; class FactoryReset : public TcBase { public: FactoryReset(TcParams params) : TcBase(params, Apid::DATA_LOGGER, static_cast(tc::DataLoggerServiceId::FACTORY_RESET), 0) {} ReturnValue_t buildPacket(uint8_t op) { setLenFromPayloadLen(1); auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } payloadStart[0] = op; return calcAndSetCrc(); } private: }; /** * @brief This class can be used to generate the space packet to set the maximum boot tries. */ class SetRestartTries : public TcBase { public: /** * @brief Constructor * * @param restartTries Maximum restart tries to set. */ SetRestartTries(TcParams params) : TcBase(params, Apid::BOOT_MAN, static_cast(tc::BootManId::SET_MAX_REBOOT_TRIES), 1) {} ReturnValue_t buildPacket(uint8_t restartTries) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(restartTries); return calcAndSetCrc(); } private: void initPacket(uint8_t restartTries) { payloadStart[0] = restartTries; } }; /** * @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. */ class DisablePeriodicHkTransmission : public TcBase { public: /** * @brief Constructor */ DisablePeriodicHkTransmission(TcParams params) : TcBase(params, Apid::HK, static_cast(tc::HkId::ENABLE), 1) {} ReturnValue_t buildPacket() { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(); return calcAndSetCrc(); } 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. */ class LatchupAlert : public TcBase { 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) */ LatchupAlert(TcParams params) : TcBase(params, Apid::LATCHUP_MON) { setLenFromPayloadLen(1); } ReturnValue_t buildPacket(bool state, uint8_t latchupId) { if (state) { setServiceId(static_cast(tc::LatchupMonId::ENABLE)); } else { setServiceId(static_cast(tc::LatchupMonId::DISABLE)); } auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(latchupId); return calcAndSetCrc(); } private: void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; } }; class SetAlertlimit : public TcBase { 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 */ SetAlertlimit(TcParams params) : TcBase(params, Apid::LATCHUP_MON, static_cast(tc::LatchupMonId::SET_ALERT_LIMIT), 5) {} ReturnValue_t buildPacket(uint8_t latchupId, uint32_t dutycycle) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } res = initPacket(latchupId, dutycycle); if (res != returnvalue::OK) { return res; } return calcAndSetCrc(); } private: ReturnValue_t initPacket(uint8_t latchupId, uint32_t dutycycle) { payloadStart[0] = latchupId; size_t serLen = 0; return SerializeAdapter::serialize(&dutycycle, payloadStart + 1, &serLen, sizeof(dutycycle), SerializeIF::Endianness::BIG); } }; /** * @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. */ class SetAdcWindowAndStride : public TcBase { public: /** * @brief Constructor * * @param windowSize * @param stridingStepSize */ SetAdcWindowAndStride(TcParams params) : TcBase(params, Apid::ADC_MON, static_cast(tc::AdcMonId::SET_WINDOW_STRIDE), 4) {} ReturnValue_t buildPacket(uint16_t windowSize, uint16_t stridingStepSize) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(windowSize, stridingStepSize); return calcAndSetCrc(); } private: void initPacket(uint16_t windowSize, uint16_t stridingStepSize) { size_t serializedSize = 6; uint8_t* data = payloadStart; SerializeAdapter::serialize(&windowSize, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&stridingStepSize, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); } }; /** * @brief This class packages the space packet to set the ADC trigger threshold. */ class SetAdcThreshold : public TcBase { public: /** * @brief Constructor * * @param threshold */ SetAdcThreshold(TcParams params) : TcBase(params, Apid::ADC_MON, static_cast(tc::AdcMonId::SET_ADC_THRESHOLD), 4) {} ReturnValue_t buildPacket(uint32_t threshold) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(threshold); return calcAndSetCrc(); } private: void initPacket(uint32_t threshold) { size_t serializedSize = 0; SerializeAdapter::serialize(&threshold, payloadStart, &serializedSize, sizeof(threshold), SerializeIF::Endianness::BIG); } }; /** * @brief This class packages the space packet to run auto EM tests. */ class RunAutoEmTests : public TcBase { public: /** * @brief Constructor * * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) */ RunAutoEmTests(TcParams params) : TcBase(params, Apid::TMTC_MAN, static_cast(tc::TmtcId::RUN_AUTO_EM_TEST), 1) {} ReturnValue_t buildPacket(uint8_t test) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(test); return calcAndSetCrc(); } private: uint8_t test = 0; void initPacket(uint8_t test) { payloadStart[0] = test; } }; /** * @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(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); } }; /** * @brief This class packages the space packet change the state of a GPIO. This command is only * required for ground testing. */ class SetGpio : public TcBase { public: /** * @brief Constructor * * @param port * @param pin * @param val */ SetGpio(TcParams params) : TcBase(params, Apid::TMTC_MAN, static_cast(tc::TmtcId::SET_GPIO), 3) {} ReturnValue_t buildPacket(uint8_t port, uint8_t pin, uint8_t val) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(port, pin, val); return calcAndSetCrc(); } 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; } }; /** * @brief This class packages the space packet causing the supervisor print the state of a GPIO * to the debug output. */ class ReadGpio : public TcBase { public: /** * @brief Constructor * * @param port * @param pin */ ReadGpio(TcParams params) : TcBase(params, Apid::TMTC_MAN, static_cast(tc::TmtcId::READ_GPIO), 2) {} ReturnValue_t buildPacket(uint8_t port, uint8_t pin) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(port, pin); return calcAndSetCrc(); } private: uint8_t port = 0; uint8_t pin = 0; void initPacket(uint8_t port, uint8_t pin) { payloadStart[0] = port; payloadStart[1] = pin; } }; class SetShutdownTimeout : public TcBase { public: SetShutdownTimeout(TcParams params) : TcBase(params, Apid::BOOT_MAN, static_cast(tc::BootManId::SHUTDOWN_TIMEOUT), 4) {} ReturnValue_t buildPacket(uint32_t timeout) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(timeout); return calcAndSetCrc(); } private: void initPacket(uint32_t timeout) { size_t serLen = 0; SerializeAdapter::serialize(&timeout, payloadStart, &serLen, sizeof(timeout), SerializeIF::Endianness::BIG); } }; /** * @brief Command to request CRC over memory region of the supervisor. */ class CheckMemory : public TcBase { public: /** * @brief Constructor * * @param memoryId * @param startAddress Start address of CRC calculation * @param length Length in bytes of memory region */ CheckMemory(TcParams params) : TcBase(params, Apid::MEM_MAN, static_cast(tc::MemManId::CHECK), 10) {} ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(memoryId, startAddress, length); return calcAndSetCrc(); } private: uint8_t n = 1; void initPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) { uint8_t* data = payloadStart; size_t serLen = 6; SerializeAdapter::serialize(&memoryId, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&n, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&startAddress, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&length, &data, &serLen, spParams.maxSize, SerializeIF::Endianness::BIG); } }; /** * @brief This class packages the space packet transporting a part of an MPSoC update. */ class WriteMemory : public TcBase { public: /** * @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 */ WriteMemory(TcParams params) : TcBase(params, Apid::MEM_MAN, static_cast(tc::MemManId::WRITE), 1) {} ReturnValue_t buildPacket(ccsds::SequenceFlags seqFlags, uint16_t sequenceCount, uint8_t memoryId, uint32_t currentAddr, uint16_t length, uint8_t* updateData) { if (length > CHUNK_MAX) { 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, currentAddr, length, updateData); if (res != returnvalue::OK) { return res; } res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } return calcAndSetCrc(); } // Although the space packet has space left for 1010 bytes of data to supervisor can only process // update packets with a maximum of 512 bytes. static const uint16_t CHUNK_MAX = 512; private: static const uint16_t META_DATA_LENGTH = 8; uint8_t n = 1; ReturnValue_t initPacket(uint8_t memoryId, uint32_t currentAddr, uint16_t updateDataLen, uint8_t* updateData) { uint8_t* data = payloadStart; if (updateDataLen % 2 != 0) { setLenFromPayloadLen(META_DATA_LENGTH + updateDataLen + 1); } else { setLenFromPayloadLen(META_DATA_LENGTH + updateDataLen); } // To avoid crashes in this unexpected case ReturnValue_t result = checkPayloadLen(); if (result != returnvalue::OK) { return result; } size_t serializedSize = MIN_TMTC_LEN; SerializeAdapter::serialize(&memoryId, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&n, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(¤tAddr, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&updateDataLen, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); std::memcpy(data, updateData, updateDataLen); if (updateDataLen % 2 != 0) { // 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 data[updateDataLen] = 0; } return returnvalue::OK; } }; /** * @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(tc::DataLoggerServiceId::WIPE_MRAM)); } else if (action == MramAction::DUMP) { setServiceId(static_cast(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(start >> 16); concatBuffer[1] = static_cast(start >> 8); concatBuffer[2] = static_cast(start); concatBuffer[3] = static_cast(stop >> 16); concatBuffer[4] = static_cast(stop >> 8); concatBuffer[5] = static_cast(stop); std::memcpy(payloadStart, concatBuffer, sizeof(concatBuffer)); } }; /** * @brief This class can be used to package erase memory command */ class EraseMemory : public TcBase { public: EraseMemory(TcParams params) : TcBase(params, Apid::MEM_MAN, static_cast(tc::MemManId::ERASE), PAYLOAD_LENGTH) {} ReturnValue_t buildPacket(uint8_t memoryId, uint32_t startAddress, uint32_t length) { auto res = checkSizeAndSerializeHeader(); if (res != returnvalue::OK) { return res; } initPacket(memoryId, startAddress, length); return calcAndSetCrc(); } 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; size_t serializedSize = 6; SerializeAdapter::serialize(&memoryId, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&n, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&startAddress, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); SerializeAdapter::serialize(&length, &data, &serializedSize, spParams.maxSize, SerializeIF::Endianness::BIG); } }; class VerificationReport { public: VerificationReport(TmBase& readerBase) : readerBase(readerBase) {} virtual ~VerificationReport() = default; virtual ReturnValue_t parse(bool checkCrc) { if (checkCrc and readerBase.checkCrc() != returnvalue::OK) { return result::CRC_FAILURE; } if (readerBase.getModuleApid() != Apid::TMTC_MAN) { return result::INVALID_APID; } if (readerBase.getBufSize() < MIN_TMTC_LEN + PAYLOAD_LEN or readerBase.getPayloadLen() < PAYLOAD_LEN) { sif::error << "VerificationReport: Invalid verification report, payload too small" << std::endl; return result::BUF_TOO_SMALL; } const uint8_t* payloadStart = readerBase.getPayloadStart(); size_t remLen = PAYLOAD_LEN; ReturnValue_t result = SerializeAdapter::deSerialize(&refApid, &payloadStart, &remLen, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { sif::warning << "VerificationReport: Failed to deserialize reference APID field" << std::endl; return result; } result = SerializeAdapter::deSerialize(&refServiceId, &payloadStart, &remLen, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { sif::warning << "VerificationReport: Failed to deserialize reference Service ID field" << std::endl; return result; } result = SerializeAdapter::deSerialize(&refSeqCount, &payloadStart, &remLen, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { sif::warning << "VerificationReport: Failed to deserialize reference sequence count field" << std::endl; return result; } result = SerializeAdapter::deSerialize(&statusCode, &payloadStart, &remLen, SerializeIF::Endianness::BIG); if (result != returnvalue::OK) { sif::warning << "VerificationReport: Failed to deserialize status code field" << std::endl; return result; } return returnvalue::OK; } /** * @brief Gets the APID of command which caused the transmission of this verification report. */ uint8_t getRefModuleApid() const { return refApid; } uint8_t getRefServiceId() const { return refServiceId; } uint16_t getRefSequenceCount() const { return refSeqCount; } uint32_t getStatusCode() const { return statusCode; } virtual void printStatusInformation(const char* prefix) const { bool codeHandled = true; if (statusCode < 0x100) { GeneralStatusCode code = static_cast(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; } } } else if (statusCode < 0x200 and statusCode >= 0x100) { BootManStatusCode code = static_cast(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: { codeHandled = false; break; } } } else if (statusCode < 0x300 and statusCode >= 0x200) { MemManStatusCode code = static_cast(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: { codeHandled = false; break; } } } else if (statusCode < 0x400 and statusCode >= 0x300) { PowerManStatusCode code = static_cast(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: { codeHandled = false; break; } } } else if (statusCode >= 0x600) { TmtcManStatusCode code = static_cast(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; break; } } } if (not codeHandled) { sif::warning << prefix << "Invalid or unimplemented status code: 0x" << std::hex << std::setfill('0') << std::setw(4) << static_cast(statusCode) << std::dec << std::endl; } } protected: 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: AcknowledgmentReport(TmBase& readerBase) : VerificationReport(readerBase) {} ReturnValue_t parse(bool checkCrc) override { if (readerBase.getServiceId() != static_cast(tm::TmtcId::ACK) and readerBase.getServiceId() != static_cast(tm::TmtcId::NAK)) { return result::INVALID_SERVICE_ID; } return VerificationReport::parse(checkCrc); } void printStatusInformationAck() { VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX); } private: static constexpr char STATUS_PRINTOUT_PREFIX[] = "SUPV NAK Status: "; }; class ExecutionReport : public VerificationReport { public: ExecutionReport(TmBase& readerBase) : VerificationReport(readerBase) {} TmBase& getReader() { return readerBase; } ReturnValue_t parse(bool checkCrc) override { if (readerBase.getServiceId() != static_cast(tm::TmtcId::EXEC_ACK) and readerBase.getServiceId() != static_cast(tm::TmtcId::EXEC_NAK)) { return returnvalue::FAILED; } return VerificationReport::parse(checkCrc); } void printStatusInformationExe() { VerificationReport::printStatusInformation(STATUS_PRINTOUT_PREFIX); } private: static constexpr char STATUS_PRINTOUT_PREFIX[] = "SUPV EXE NAK Status: "; }; class UpdateStatusReport { public: UpdateStatusReport(TmBase& tmReader) : tmReader(tmReader) {} ReturnValue_t parse(bool checkCrc) { if (checkCrc and tmReader.checkCrc() != returnvalue::OK) { return result::CRC_FAILURE; } if (tmReader.getModuleApid() != Apid::MEM_MAN) { 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; } size_t remLen = tmReader.getPayloadLen(); 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; }; /** * @brief This dataset stores the boot status report of the supervisor. */ class BootStatusReport : public StaticLocalDataSet { 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 */ lp_var_t socState = lp_var_t(sid.objectId, PoolIds::BR_SOC_STATE, this); lp_var_t powerCycles = lp_var_t(sid.objectId, PoolIds::POWER_CYCLES, this); /** Time the MPSoC needs for last boot */ lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); /** The currently set boot timeout */ lp_var_t bootTimeoutMs = lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_POOL_VAR_MS, this); lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); /** States of the boot partition pins */ lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); lp_var_t bootState = lp_var_t(sid.objectId, PoolIds::BOOT_STATE, this); lp_var_t bootCycles = lp_var_t(sid.objectId, PoolIds::BOOT_CYCLES, this); }; /** * @brief This dataset stores the housekeeping data of the supervisor. */ class HkSet : public StaticLocalDataSet { public: enum class SocState { OFF = 0, BOOTING = 1, OPERATIONAL = 3, SHUTDOWN = 4 }; HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); lp_var_t socState = lp_var_t(sid.objectId, PoolIds::HK_SOC_STATE, this); lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); lp_var_t missionIoState = lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); }; /** * @brief This dataset stores the last requested latchup status report. */ class LatchupStatusReport : public StaticLocalDataSet { public: LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); lp_var_t timeMsec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); lp_var_t timeHour = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); lp_var_t timeYear = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); lp_var_t isSynced = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_IS_SET, this); static const uint8_t IS_SET_BIT_POS = 15; }; /** * @brief This dataset stores the logging report. */ class CountersReport : public StaticLocalDataSet { public: CountersReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LOGGING_RPT_ID) {} CountersReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LOGGING_RPT_ID)) {} lp_var_t signature = lp_var_t(sid.objectId, PoolIds::LATCHUP_HAPPENED_CNTS, this); lp_vec_t latchupHappenCnts = lp_vec_t(sid.objectId, PoolIds::LATCHUP_HAPPENED_CNTS, this); lp_var_t adcDeviationTriggersCnt = lp_var_t(sid.objectId, PoolIds::ADC_DEVIATION_TRIGGERS_CNT, this); lp_var_t tcReceivedCnt = lp_var_t(sid.objectId, PoolIds::TC_RECEIVED_CNT, this); lp_var_t tmAvailableCnt = lp_var_t(sid.objectId, PoolIds::TM_AVAILABLE_CNT, this); lp_var_t supervisorBoots = lp_var_t(sid.objectId, PoolIds::SUPERVISOR_BOOTS, this); lp_var_t mpsocBoots = lp_var_t(sid.objectId, PoolIds::MPSOC_BOOTS, this); lp_var_t mpsocBootFailedAttempts = lp_var_t(sid.objectId, PoolIds::MPSOC_BOOT_FAILED_ATTEMPTS, this); lp_var_t mpsocPowerup = lp_var_t(sid.objectId, PoolIds::MPSOC_POWER_UP, this); lp_var_t mpsocUpdates = lp_var_t(sid.objectId, PoolIds::MPSOC_UPDATES, this); lp_var_t mpsocHeartbeatResets = lp_var_t(sid.objectId, PoolIds::MPSOC_HEARTBEAT_RESETS, this); lp_var_t cpuWdtResets = lp_var_t(sid.objectId, PoolIds::MPSOC_HEARTBEAT_RESETS, this); lp_var_t psHeartbeatsLost = lp_var_t(sid.objectId, PoolIds::PS_HEARTBEATS_LOST, this); lp_var_t plHeartbeatsLost = lp_var_t(sid.objectId, PoolIds::PL_HEARTBEATS_LOST, this); lp_var_t ebTaskLost = lp_var_t(sid.objectId, PoolIds::EB_TASK_LOST, this); lp_var_t bmTaskLost = lp_var_t(sid.objectId, PoolIds::BM_TASK_LOST, this); lp_var_t lmTaskLost = lp_var_t(sid.objectId, PoolIds::LM_TASK_LOST, this); lp_var_t amTaskLost = lp_var_t(sid.objectId, PoolIds::AM_TASK_LOST, this); lp_var_t tctmmTaskLost = lp_var_t(sid.objectId, PoolIds::TCTMM_TASK_LOST, this); lp_var_t mmTaskLost = lp_var_t(sid.objectId, PoolIds::MM_TASK_LOST, this); lp_var_t hkTaskLost = lp_var_t(sid.objectId, PoolIds::HK_TASK_LOST, this); lp_var_t dlTaskLost = lp_var_t(sid.objectId, PoolIds::DL_TASK_LOST, this); lp_vec_t rwsTasksLost = lp_vec_t(sid.objectId, PoolIds::RWS_TASKS_LOST, this); void printSet() { 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; 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; sif::info << "LoggingReport: MPSoC power up: " << this->mpsocPowerup << std::endl; sif::info << "LoggingReport: MPSoC updates: " << this->mpsocUpdates << std::endl; } }; /** * @brief This dataset stores the ADC report. */ class AdcReport : public StaticLocalDataSet<3> { public: AdcReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, ADC_REPORT_SET_ID) {} AdcReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ADC_REPORT_SET_ID)) {} lp_vec_t adcRaw = lp_vec_t(sid.objectId, PoolIds::ADC_RAW, this); lp_vec_t adcEng = lp_vec_t(sid.objectId, PoolIds::ADC_ENG, this); void printSet() { sif::info << "---- Adc Report: Raw values ----" << std::endl; 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; } } }; 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 */ 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 */ 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: 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(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 } // namespace supv #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */