From ea2260a61d45d9b9d8131f17cf826695603fa2f2 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" <–meierj@irs.uni-stuttgart.de> Date: Tue, 13 Jul 2021 08:32:14 +0200 Subject: [PATCH] few commands implemented for the ploc supervisor --- bsp_q7s/core/ObjectFactory.cpp | 32 +- bsp_q7s/core/obsw.cpp | 1 + common/config/commonClassIds.h | 3 +- common/config/commonObjects.h | 3 +- common/config/commonSubsystemIds.h | 3 +- fsfw_hal | 2 +- generators/bsp_q7s_events.csv | 12 +- generators/bsp_q7s_objects.csv | 12 +- generators/events/translateEvents.cpp | 16 +- generators/objects/translateObjects.cpp | 38 +- linux/fsfwconfig/OBSWConfig.h.in | 9 +- linux/fsfwconfig/events/translateEvents.cpp | 16 +- linux/fsfwconfig/objects/translateObjects.cpp | 38 +- .../pollingSequenceFactory.cpp | 34 +- .../pollingsequence/pollingSequenceFactory.h | 2 +- mission/devices/CMakeLists.txt | 3 +- .../{PlocHandler.cpp => PlocMPSoCHandler.cpp} | 236 +++---- .../{PlocHandler.h => PlocMPSoCHandler.h} | 27 +- mission/devices/PlocSupervisorHandler.cpp | 581 ++++++++++++++++++ mission/devices/PlocSupervisorHandler.h | 202 ++++++ mission/devices/RadiationSensorHandler.cpp | 54 +- ...ocDefinitions.h => PlocMPSoCDefinitions.h} | 8 +- .../PlocSupervisorDefinitions.h | 324 ++++++++++ .../devicedefinitions/RadSensorDefinitions.h | 28 +- .../devices/devicedefinitions/RwDefinitions.h | 2 +- .../StarTrackerDefinitions.h | 2 +- tmtc | 2 +- 27 files changed, 1456 insertions(+), 234 deletions(-) rename mission/devices/{PlocHandler.cpp => PlocMPSoCHandler.cpp} (53%) rename mission/devices/{PlocHandler.h => PlocMPSoCHandler.h} (89%) create mode 100644 mission/devices/PlocSupervisorHandler.cpp create mode 100644 mission/devices/PlocSupervisorHandler.h rename mission/devices/devicedefinitions/{PlocDefinitions.h => PlocMPSoCDefinitions.h} (96%) create mode 100644 mission/devices/devicedefinitions/PlocSupervisorDefinitions.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 2aaf5264..6bf90306 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -30,13 +30,13 @@ #include #include #include -#include +#include +#include #include #include #include #include #include -#include #include #include #include @@ -63,6 +63,7 @@ #include #include #include +#include #if TEST_LIBGPIOD == 1 #include @@ -550,9 +551,9 @@ void ObjectFactory::produce(void* args){ std::string("/dev/i2c-0")); new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); - UartCookie* plocUartCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), - UartModes::NON_CANONICAL, 115200, PLOC::MAX_REPLY_SIZE); - new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); + UartCookie* plocMpsocCookie = new UartCookie(objects::RW1, std::string("/dev/ttyUL3"), + UartModes::NON_CANONICAL, 115200, PLOC_MPSOC::MAX_REPLY_SIZE); + new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie); GpioCookie* gpioCookieRw = new GpioCookie; GpioCallback* csRw1 = new GpioCallback(std::string("Chip select reaction wheel 1"), gpio::OUT, @@ -621,10 +622,12 @@ void ObjectFactory::produce(void* args){ gpioIds::EN_RW4); rw4SpiCookie->setCallbackArgs(rwHandler4); +#if OBSW_ADD_STAR_TRACKER == 1 UartCookie* starTrackerCookie = new UartCookie(objects::START_TRACKER, std::string("/dev/ttyUL3"), UartModes::NON_CANONICAL, 115200, StarTracker::MAX_FRAME_SIZE* 2 + 2); starTrackerCookie->setNoFixedSizeReply(); new StarTrackerHandler(objects::START_TRACKER, objects::UART_COM_IF, starTrackerCookie); +#endif #endif /* TE0720 == 0 */ @@ -686,11 +689,11 @@ void ObjectFactory::produce(void* args){ #if TE0720 == 1 && TEST_PLOC_HANDLER == 1 UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyPS1"), 115200, - PLOC::MAX_REPLY_SIZE); - /* Testing PlocHandler on TE0720-03-1CFA */ - PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, + PLOC_MPSOC::MAX_REPLY_SIZE); + /* Testing PlocMPSoCHandler on TE0720-03-1CFA */ + PlocMPSoCHandler* mpsocPlocHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocUartCookie); - plocHandler->setStartUpImmediately(); + mpsocPlocHandler->setStartUpImmediately(); #endif #if TE0720 == 1 && TE0720_HEATER_TEST == 1 @@ -702,6 +705,17 @@ void ObjectFactory::produce(void* args){ pcduSwitches::TCS_BOARD_8V_HEATER_IN); #endif +#if TE0720 == 1 && ADD_PLOC_SUPERVISOR == 1 + /* Configuration for MIO0 on TE0720-03-1CFA */ + UartCookie* plocSupervisorCookie = new UartCookie(objects::PLOC_SUPERVISOR_HANDLER, + std::string("/dev/ttyPS1"), UartModes::NON_CANONICAL, 115200, + PLOC_SPV::MAX_REPLY_SIZE); + PlocSupervisorHandler* plocSupervisor = new PlocSupervisorHandler( + objects::PLOC_SUPERVISOR_HANDLER, objects::UART_COM_IF, plocSupervisorCookie); + plocSupervisor->setStartUpImmediately(); + +#endif + #if Q7S_ADD_SPI_TEST == 1 new SpiTestClass(objects::SPI_TEST, gpioComIF); #endif diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index f813bcae..a6bdb61b 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -2,6 +2,7 @@ #include "OBSWVersion.h" #include "InitMission.h" #include "fsfw/tasks/TaskFactory.h" +#include "OBSWConfig.h" #include int obsw::obsw() { diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index b0cbef75..977cbdb2 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -15,7 +15,8 @@ enum commonClassIds: uint8_t { IMTQ_HANDLER, //IMTQ RW_HANDLER, //Reaction Wheels STR_HANDLER, //Star tracker - PLOC_HANDLER, //PLOC + PLOC_MPSOC_HANDLER, //PLOC MPSoC + PLOC_SUPERVISOR_HANDLER, //PLOC Supervisor SUS_HANDLER, //SUSS CCSDS_IP_CORE_BRIDGE, // IP Core interface COMMON_CLASS_ID_END // [EXPORT] : [END] diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index a237cbd5..458b9a5f 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -33,7 +33,8 @@ enum commonObjects: uint32_t { GYRO_3_L3G_HANDLER = 0x44120313, IMTQ_HANDLER = 0x44140014, - PLOC_HANDLER = 0x44330015, + PLOC_MPSOC_HANDLER = 0x44330015, + PLOC_SUPERVISOR_HANDLER = 0x44330016, /** * Not yet specified which pt1000 will measure which device/location in the satellite. diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 288268c9..a86cb5a0 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -11,10 +11,11 @@ enum: uint8_t { PCDU_HANDLER = 108, HEATER_HANDLER = 109, SA_DEPL_HANDLER = 110, - PLOC_HANDLER = 111, + PLOC_MPSOC_HANDLER = 111, IMTQ_HANDLER = 112, RW_HANDLER = 113, STR_HANDLER = 114, + PLOC_SUPERVISOR_HANDLER = 115, COMMON_SUBSYSTEM_ID_END }; } diff --git a/fsfw_hal b/fsfw_hal index 866868b2..88769bb4 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 866868b25fcde7ca936a59e2830508235603feb7 +Subproject commit 88769bb46c34917f49c1d93abb0b1894b934b32c diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index c895aebb..d19a79a3 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -77,10 +77,10 @@ 8901;CLOCK_SET_FAILURE;LOW; ;../../fsfw/pus/Service9TimeManagement.h 9700;TEST;INFO; ;../../fsfw/pus/Service17Test.h 10600;CHANGE_OF_SETUP_PARAMETER;LOW; ;../../mission/devices/MGMHandlerLIS3MDL.h -11101;MEMORY_READ_RPT_CRC_FAILURE;LOW; ;../../mission/devices/PlocHandler.h -11102;ACK_FAILURE;LOW; ;../../mission/devices/PlocHandler.h -11103;EXE_FAILURE;LOW; ;../../mission/devices/PlocHandler.h -11104;CRC_FAILURE_EVENT;LOW; ;../../mission/devices/PlocHandler.h +11101;MEMORY_READ_RPT_CRC_FAILURE;LOW; ;../../mission/devices/PlocMPSoCHandler.h +11102;ACK_FAILURE;LOW; ;../../mission/devices/PlocMPSoCHandler.h +11103;EXE_FAILURE;LOW; ;../../mission/devices/PlocMPSoCHandler.h +11104;CRC_FAILURE_EVENT;LOW; ;../../mission/devices/PlocMPSoCHandler.h 11201;SELF_TEST_I2C_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h 11202;SELF_TEST_SPI_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h 11203;SELF_TEST_ADC_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h @@ -90,3 +90,7 @@ 11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW; ;../../mission/devices/IMTQHandler.h 11208;INVALID_ERROR_BYTE;LOW; ;../../mission/devices/IMTQHandler.h 11301;ERROR_STATE;HIGH; ;../../mission/devices/RwHandler.h +11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW; ;../../mission/devices/PlocSupervisorHandler.h +11502;SUPV_ACK_FAILURE;LOW; ;../../mission/devices/PlocSupervisorHandler.h +11503;SUPV_EXE_FAILURE;LOW; ;../../mission/devices/PlocSupervisorHandler.h +11504;SUPV_CRC_FAILURE_EVENT;LOW; ;../../mission/devices/PlocSupervisorHandler.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index e0180089..cf3e082a 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -2,6 +2,10 @@ 0x43000003;CORE_CONTROLLER 0x43100002;ACS_CONTROLLER 0x43400001;THERMAL_CONTROLLER +0x44120001;RW1 +0x44120002;RW2 +0x44120003;RW3 +0x44120004;RW4 0x44120006;MGM_0_LIS3_HANDLER 0x44120010;GYRO_0_ADIS_HANDLER 0x44120032;SUS_1 @@ -23,20 +27,18 @@ 0x44120212;GYRO_2_ADIS_HANDLER 0x44120309;MGM_3_RM3100_HANDLER 0x44120313;GYRO_3_L3G_HANDLER +0x44130001;START_TRACKER 0x44130045;GPS0_HANDLER 0x44130146;GPS1_HANDLER 0x44140014;IMTQ_HANDLER 0x442000A1;PCDU_HANDLER -0x44210001;RW1 -0x44210002;RW2 -0x44210003;RW3 -0x44210004;RW4 0x44250000;P60DOCK_HANDLER 0x44250001;PDU1_HANDLER 0x44250002;PDU2_HANDLER 0x44250003;ACU_HANDLER 0x443200A5;RAD_SENSOR -0x44330015;PLOC_HANDLER +0x44330015;PLOC_MPSOC_HANDLER +0x44330016;PLOC_SUPERVISOR_HANDLER 0x444100A2;SOLAR_ARRAY_DEPL_HANDLER 0x444100A4;HEATER_HANDLER 0x44420004;TMP1075_HANDLER_1 diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 9ae81646..20521618 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 92 translations. + * @brief Auto-generated event translation file. Contains 96 translations. * @details - * Generated on: 2021-06-29 16:20:09 + * Generated on: 2021-07-12 15:20:38 */ #include "translateEvents.h" @@ -97,6 +97,10 @@ const char *SELF_TEST_MTM_RANGE_FAILURE_STRING = "SELF_TEST_MTM_RANGE_FAILURE"; const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE"; const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; const char *ERROR_STATE_STRING = "ERROR_STATE"; +const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE"; +const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; +const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; +const char *SUPV_CRC_FAILURE_EVENT_STRING = "SUPV_CRC_FAILURE_EVENT"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -284,6 +288,14 @@ const char * translateEvents(Event event) { return INVALID_ERROR_BYTE_STRING; case(11301): return ERROR_STATE_STRING; + case(11501): + return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; + case(11502): + return SUPV_ACK_FAILURE_STRING; + case(11503): + return SUPV_EXE_FAILURE_STRING; + case(11504): + return SUPV_CRC_FAILURE_EVENT_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 2068158b..cf9db4ca 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 100 translations. - * Generated on: 2021-06-29 16:19:57 + * Contains 102 translations. + * Generated on: 2021-07-10 16:22:55 */ #include "translateObjects.h" @@ -10,6 +10,10 @@ const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; +const char *RW1_STRING = "RW1"; +const char *RW2_STRING = "RW2"; +const char *RW3_STRING = "RW3"; +const char *RW4_STRING = "RW4"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; const char *SUS_1_STRING = "SUS_1"; @@ -31,20 +35,18 @@ const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; const char *GYRO_2_ADIS_HANDLER_STRING = "GYRO_2_ADIS_HANDLER"; const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; +const char *START_TRACKER_STRING = "START_TRACKER"; const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; const char *PCDU_HANDLER_STRING = "PCDU_HANDLER"; -const char *RW1_STRING = "RW1"; -const char *RW2_STRING = "RW2"; -const char *RW3_STRING = "RW3"; -const char *RW4_STRING = "RW4"; const char *P60DOCK_HANDLER_STRING = "P60DOCK_HANDLER"; const char *PDU1_HANDLER_STRING = "PDU1_HANDLER"; const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; -const char *PLOC_HANDLER_STRING = "PLOC_HANDLER"; +const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; +const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; @@ -117,6 +119,14 @@ const char* translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43400001: return THERMAL_CONTROLLER_STRING; + case 0x44120001: + return RW1_STRING; + case 0x44120002: + return RW2_STRING; + case 0x44120003: + return RW3_STRING; + case 0x44120004: + return RW4_STRING; case 0x44120006: return MGM_0_LIS3_HANDLER_STRING; case 0x44120010: @@ -159,6 +169,8 @@ const char* translateObject(object_id_t object) { return MGM_3_RM3100_HANDLER_STRING; case 0x44120313: return GYRO_3_L3G_HANDLER_STRING; + case 0x44130001: + return START_TRACKER_STRING; case 0x44130045: return GPS0_HANDLER_STRING; case 0x44130146: @@ -167,14 +179,6 @@ const char* translateObject(object_id_t object) { return IMTQ_HANDLER_STRING; case 0x442000A1: return PCDU_HANDLER_STRING; - case 0x44210001: - return RW1_STRING; - case 0x44210002: - return RW2_STRING; - case 0x44210003: - return RW3_STRING; - case 0x44210004: - return RW4_STRING; case 0x44250000: return P60DOCK_HANDLER_STRING; case 0x44250001: @@ -186,7 +190,9 @@ const char* translateObject(object_id_t object) { case 0x443200A5: return RAD_SENSOR_STRING; case 0x44330015: - return PLOC_HANDLER_STRING; + return PLOC_MPSOC_HANDLER_STRING; + case 0x44330016: + return PLOC_SUPERVISOR_HANDLER_STRING; case 0x444100A2: return SOLAR_ARRAY_DEPL_HANDLER_STRING; case 0x444100A4: diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index aca0af91..4b84b3f1 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -21,15 +21,17 @@ debugging. */ #define OBSW_ADD_TEST_CODE 1 #define OBSW_ADD_TEST_PST 1 #define OBSW_ADD_GPS 0 +#define OBSW_ADD_STAR_TRACKER 0 #define TEST_LIBGPIOD 0 #define TEST_RADIATION_SENSOR_HANDLER 0 -#define TEST_SUS_HANDLER 1 +#define TEST_SUS_HANDLER 0 #define TEST_PLOC_HANDLER 0 #define TEST_CCSDS_BRIDGE 0 #define PERFORM_PTME_TEST 0 +#define ADD_PLOC_SUPERVISOR 1 -#define TE0720 0 +#define TE0720 1 #define TE0720_HEATER_TEST 0 #define P60DOCK_DEBUG 0 @@ -45,7 +47,8 @@ debugging. */ #define DEBUG_RTD 1 #define IMTQ_DEBUG 1 #define RW_DEBUG 0 -#define START_TRACKER_DEBUG 1 +#define START_TRACKER_DEBUG 0 +#define PLOC_MPSOC_DEBUG 1 // Leave at one as the BSP is linux. Used by the ADIS16507 device handler #define OBSW_ADIS16507_LINUX_COM_IF 1 diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 9ae81646..20521618 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 92 translations. + * @brief Auto-generated event translation file. Contains 96 translations. * @details - * Generated on: 2021-06-29 16:20:09 + * Generated on: 2021-07-12 15:20:38 */ #include "translateEvents.h" @@ -97,6 +97,10 @@ const char *SELF_TEST_MTM_RANGE_FAILURE_STRING = "SELF_TEST_MTM_RANGE_FAILURE"; const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE"; const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; const char *ERROR_STATE_STRING = "ERROR_STATE"; +const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE"; +const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; +const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; +const char *SUPV_CRC_FAILURE_EVENT_STRING = "SUPV_CRC_FAILURE_EVENT"; const char * translateEvents(Event event) { switch( (event & 0xffff) ) { @@ -284,6 +288,14 @@ const char * translateEvents(Event event) { return INVALID_ERROR_BYTE_STRING; case(11301): return ERROR_STATE_STRING; + case(11501): + return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; + case(11502): + return SUPV_ACK_FAILURE_STRING; + case(11503): + return SUPV_EXE_FAILURE_STRING; + case(11504): + return SUPV_CRC_FAILURE_EVENT_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 2068158b..cf9db4ca 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,8 +1,8 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 100 translations. - * Generated on: 2021-06-29 16:19:57 + * Contains 102 translations. + * Generated on: 2021-07-10 16:22:55 */ #include "translateObjects.h" @@ -10,6 +10,10 @@ const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; +const char *RW1_STRING = "RW1"; +const char *RW2_STRING = "RW2"; +const char *RW3_STRING = "RW3"; +const char *RW4_STRING = "RW4"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; const char *GYRO_0_ADIS_HANDLER_STRING = "GYRO_0_ADIS_HANDLER"; const char *SUS_1_STRING = "SUS_1"; @@ -31,20 +35,18 @@ const char *MGM_2_LIS3_HANDLER_STRING = "MGM_2_LIS3_HANDLER"; const char *GYRO_2_ADIS_HANDLER_STRING = "GYRO_2_ADIS_HANDLER"; const char *MGM_3_RM3100_HANDLER_STRING = "MGM_3_RM3100_HANDLER"; const char *GYRO_3_L3G_HANDLER_STRING = "GYRO_3_L3G_HANDLER"; +const char *START_TRACKER_STRING = "START_TRACKER"; const char *GPS0_HANDLER_STRING = "GPS0_HANDLER"; const char *GPS1_HANDLER_STRING = "GPS1_HANDLER"; const char *IMTQ_HANDLER_STRING = "IMTQ_HANDLER"; const char *PCDU_HANDLER_STRING = "PCDU_HANDLER"; -const char *RW1_STRING = "RW1"; -const char *RW2_STRING = "RW2"; -const char *RW3_STRING = "RW3"; -const char *RW4_STRING = "RW4"; const char *P60DOCK_HANDLER_STRING = "P60DOCK_HANDLER"; const char *PDU1_HANDLER_STRING = "PDU1_HANDLER"; const char *PDU2_HANDLER_STRING = "PDU2_HANDLER"; const char *ACU_HANDLER_STRING = "ACU_HANDLER"; const char *RAD_SENSOR_STRING = "RAD_SENSOR"; -const char *PLOC_HANDLER_STRING = "PLOC_HANDLER"; +const char *PLOC_MPSOC_HANDLER_STRING = "PLOC_MPSOC_HANDLER"; +const char *PLOC_SUPERVISOR_HANDLER_STRING = "PLOC_SUPERVISOR_HANDLER"; const char *SOLAR_ARRAY_DEPL_HANDLER_STRING = "SOLAR_ARRAY_DEPL_HANDLER"; const char *HEATER_HANDLER_STRING = "HEATER_HANDLER"; const char *TMP1075_HANDLER_1_STRING = "TMP1075_HANDLER_1"; @@ -117,6 +119,14 @@ const char* translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43400001: return THERMAL_CONTROLLER_STRING; + case 0x44120001: + return RW1_STRING; + case 0x44120002: + return RW2_STRING; + case 0x44120003: + return RW3_STRING; + case 0x44120004: + return RW4_STRING; case 0x44120006: return MGM_0_LIS3_HANDLER_STRING; case 0x44120010: @@ -159,6 +169,8 @@ const char* translateObject(object_id_t object) { return MGM_3_RM3100_HANDLER_STRING; case 0x44120313: return GYRO_3_L3G_HANDLER_STRING; + case 0x44130001: + return START_TRACKER_STRING; case 0x44130045: return GPS0_HANDLER_STRING; case 0x44130146: @@ -167,14 +179,6 @@ const char* translateObject(object_id_t object) { return IMTQ_HANDLER_STRING; case 0x442000A1: return PCDU_HANDLER_STRING; - case 0x44210001: - return RW1_STRING; - case 0x44210002: - return RW2_STRING; - case 0x44210003: - return RW3_STRING; - case 0x44210004: - return RW4_STRING; case 0x44250000: return P60DOCK_HANDLER_STRING; case 0x44250001: @@ -186,7 +190,9 @@ const char* translateObject(object_id_t object) { case 0x443200A5: return RAD_SENSOR_STRING; case 0x44330015: - return PLOC_HANDLER_STRING; + return PLOC_MPSOC_HANDLER_STRING; + case 0x44330016: + return PLOC_SUPERVISOR_HANDLER_STRING; case 0x444100A2: return SOLAR_ARRAY_DEPL_HANDLER_STRING; case 0x444100A4: diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 766efc40..a6d35b5e 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -449,7 +449,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { // Length of a communication cycle uint32_t length = thisSequence->getPeriodMs(); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); @@ -460,7 +460,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::PERFORM_OPERATION); #endif - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); @@ -471,7 +471,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::SEND_WRITE); #endif - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); @@ -482,7 +482,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_WRITE); #endif - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); @@ -493,7 +493,7 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::SEND_READ); #endif - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::SYRLINKS_HK_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); @@ -504,11 +504,13 @@ ReturnValue_t pst::pstUart(FixedTimeslotTaskIF *thisSequence) { DeviceHandlerIF::GET_READ); #endif +#if OBSW_ADD_STAR_TRACKER == 1 thisSequence->addSlot(objects::START_TRACKER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::START_TRACKER, length * 0.2, DeviceHandlerIF::SEND_WRITE); thisSequence->addSlot(objects::START_TRACKER, length * 0.4, DeviceHandlerIF::GET_WRITE); thisSequence->addSlot(objects::START_TRACKER, length * 0.6, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::START_TRACKER, length * 0.8, DeviceHandlerIF::GET_READ); +#endif if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "UART PST initialization failed" << std::endl; @@ -676,16 +678,16 @@ ReturnValue_t pst::pstTest(FixedTimeslotTaskIF* thisSequence) { return HasReturnvaluesIF::RETURN_OK; } -#if TE7020 == 1 +#if TE0720 == 1 ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { uint32_t length = thisSequence->getPeriodMs(); -#if TEST_PLOC_HANDLER == 1 - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::PLOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#if TEST_PLOC_MPSOC_HANDLER == 1 + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.6, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_MPSOC_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); #endif #if TEST_RADIATION_SENSOR_HANDLER == 1 @@ -719,6 +721,14 @@ ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::SUS_1, length * 0.915, DeviceHandlerIF::GET_READ); #endif +#if ADD_PLOC_SUPERVISOR == 1 + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.2, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.4, DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.7, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::PLOC_SUPERVISOR_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); +#endif + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { sif::error << "Initialization of TE0720 PST failed" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index a2b5edfb..4ce1619c 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -55,7 +55,7 @@ ReturnValue_t pstI2c(FixedTimeslotTaskIF* thisSequence); */ ReturnValue_t pstTest(FixedTimeslotTaskIF* thisSequence); -#if TE7020 == 1 +#if TE0720 == 1 /** * @brief This polling sequence will be created when the software is compiled for the TE0720. */ diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index c49a29db..63b417e9 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -12,7 +12,8 @@ target_sources(${TARGET_NAME} PUBLIC SyrlinksHkHandler.cpp Max31865PT1000Handler.cpp IMTQHandler.cpp - PlocHandler.cpp + PlocMPSoCHandler.cpp + PlocSupervisorHandler.cpp RadiationSensorHandler.cpp GyroADIS16507Handler.cpp RwHandler.cpp diff --git a/mission/devices/PlocHandler.cpp b/mission/devices/PlocMPSoCHandler.cpp similarity index 53% rename from mission/devices/PlocHandler.cpp rename to mission/devices/PlocMPSoCHandler.cpp index 2101915a..0b1fac73 100644 --- a/mission/devices/PlocHandler.cpp +++ b/mission/devices/PlocMPSoCHandler.cpp @@ -1,66 +1,66 @@ -#include "PlocHandler.h" +#include "PlocMPSoCHandler.h" #include "OBSWConfig.h" #include #include -PlocHandler::PlocHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : +PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : DeviceHandlerBase(objectId, comIF, comCookie) { if (comCookie == NULL) { - sif::error << "PlocHandler: Invalid com cookie" << std::endl; + sif::error << "PlocMPSoCHandler: Invalid com cookie" << std::endl; } } -PlocHandler::~PlocHandler() { +PlocMPSoCHandler::~PlocMPSoCHandler() { } -void PlocHandler::doStartUp(){ +void PlocMPSoCHandler::doStartUp(){ if(mode == _MODE_START_UP){ setMode(MODE_ON); } } -void PlocHandler::doShutDown(){ +void PlocMPSoCHandler::doShutDown(){ } -ReturnValue_t PlocHandler::buildNormalDeviceCommand( +ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand( DeviceCommandId_t * id) { return RETURN_OK; } -ReturnValue_t PlocHandler::buildTransitionDeviceCommand( +ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand( DeviceCommandId_t * id){ return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PlocHandler::buildCommandFromCommand( +ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand( DeviceCommandId_t deviceCommand, const uint8_t * commandData, size_t commandDataLen) { switch(deviceCommand) { - case(PLOC::TC_MEM_WRITE): { + case(PLOC_MPSOC::TC_MEM_WRITE): { return prepareTcMemWriteCommand(commandData, commandDataLen); } - case(PLOC::TC_MEM_READ): { + case(PLOC_MPSOC::TC_MEM_READ): { return prepareTcMemReadCommand(commandData, commandDataLen); } default: - sif::debug << "PlocHandler::buildCommandFromCommand: Command not implemented" << std::endl; + sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented" << std::endl; return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } return HasReturnvaluesIF::RETURN_FAILED; } -void PlocHandler::fillCommandAndReplyMap() { - this->insertInCommandMap(PLOC::TC_MEM_WRITE); - this->insertInCommandMap(PLOC::TC_MEM_READ); - this->insertInReplyMap(PLOC::ACK_REPORT, 1, nullptr, PLOC::SIZE_ACK_REPORT); - this->insertInReplyMap(PLOC::EXE_REPORT, 3, nullptr, PLOC::SIZE_EXE_REPORT); - this->insertInReplyMap(PLOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC::SIZE_TM_MEM_READ_REPORT); +void PlocMPSoCHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_WRITE); + this->insertInCommandMap(PLOC_MPSOC::TC_MEM_READ); + this->insertInReplyMap(PLOC_MPSOC::ACK_REPORT, 1, nullptr, PLOC_MPSOC::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_MPSOC::EXE_REPORT, 3, nullptr, PLOC_MPSOC::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_MPSOC::TM_MEMORY_READ_REPORT, 2, nullptr, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); } -ReturnValue_t PlocHandler::scanForReply(const uint8_t *start, +ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { ReturnValue_t result = RETURN_OK; @@ -68,28 +68,28 @@ ReturnValue_t PlocHandler::scanForReply(const uint8_t *start, uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; switch(apid) { - case(PLOC::APID_ACK_SUCCESS): - *foundLen = PLOC::SIZE_ACK_REPORT; - *foundId = PLOC::ACK_REPORT; + case(PLOC_MPSOC::APID_ACK_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; break; - case(PLOC::APID_ACK_FAILURE): - *foundLen = PLOC::SIZE_ACK_REPORT; - *foundId = PLOC::ACK_REPORT; + case(PLOC_MPSOC::APID_ACK_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_ACK_REPORT; + *foundId = PLOC_MPSOC::ACK_REPORT; break; - case(PLOC::APID_TM_MEMORY_READ_REPORT): - *foundLen = PLOC::SIZE_TM_MEM_READ_REPORT; - *foundId = PLOC::TM_MEMORY_READ_REPORT; + case(PLOC_MPSOC::APID_TM_MEMORY_READ_REPORT): + *foundLen = PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT; + *foundId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; break; - case(PLOC::APID_EXE_SUCCESS): - *foundLen = PLOC::SIZE_EXE_REPORT; - *foundId = PLOC::EXE_REPORT; + case(PLOC_MPSOC::APID_EXE_SUCCESS): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; break; - case(PLOC::APID_EXE_FAILURE): - *foundLen = PLOC::SIZE_EXE_REPORT; - *foundId = PLOC::EXE_REPORT; + case(PLOC_MPSOC::APID_EXE_FAILURE): + *foundLen = PLOC_MPSOC::SIZE_EXE_REPORT; + *foundId = PLOC_MPSOC::EXE_REPORT; break; default: { - sif::debug << "PlocHandler::scanForReply: Reply has invalid apid" << std::endl; + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; *foundLen = remainingSize; return INVALID_APID; } @@ -104,26 +104,26 @@ ReturnValue_t PlocHandler::scanForReply(const uint8_t *start, return result; } -ReturnValue_t PlocHandler::interpretDeviceReply(DeviceCommandId_t id, +ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { ReturnValue_t result = RETURN_OK; switch (id) { - case PLOC::ACK_REPORT: { + case PLOC_MPSOC::ACK_REPORT: { result = handleAckReport(packet); break; } - case (PLOC::TM_MEMORY_READ_REPORT): { + case (PLOC_MPSOC::TM_MEMORY_READ_REPORT): { result = handleMemoryReadReport(packet); break; } - case (PLOC::EXE_REPORT): { + case (PLOC_MPSOC::EXE_REPORT): { result = handleExecutionReport(packet); break; } default: { - sif::debug << "PlocHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + sif::debug << "PlocMPSoCHandler::interpretDeviceReply: Unknown device reply id" << std::endl; return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; } } @@ -131,62 +131,62 @@ ReturnValue_t PlocHandler::interpretDeviceReply(DeviceCommandId_t id, return result; } -void PlocHandler::setNormalDatapoolEntriesInvalid(){ +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid(){ } -uint32_t PlocHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ return 500; } -ReturnValue_t PlocHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, +ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { return HasReturnvaluesIF::RETURN_OK; } -void PlocHandler::setModeNormal() { +void PlocMPSoCHandler::setModeNormal() { mode = MODE_NORMAL; } -ReturnValue_t PlocHandler::prepareTcMemWriteCommand(const uint8_t * commandData, +ReturnValue_t PlocMPSoCHandler::prepareTcMemWriteCommand(const uint8_t * commandData, size_t commandDataLen) { const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); const uint32_t memoryData = *(commandData + 4) << 24 | *(commandData + 5) << 16 | *(commandData + 6) << 8 | *(commandData + 7); packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); - if (tcMemWrite.getFullSize() > PLOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocHandler::prepareTcMemWriteCommand: Command too big" << std::endl; + PLOC_MPSOC::TcMemWrite tcMemWrite(memoryAddress, memoryData, packetSequenceCount); + if (tcMemWrite.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemWriteCommand: Command too big" << std::endl; return RETURN_FAILED; } memcpy(commandBuffer, tcMemWrite.getWholeData(), tcMemWrite.getFullSize()); rawPacket = commandBuffer; rawPacketLen = tcMemWrite.getFullSize(); - nextReplyId = PLOC::ACK_REPORT; + nextReplyId = PLOC_MPSOC::ACK_REPORT; return RETURN_OK; } -ReturnValue_t PlocHandler::prepareTcMemReadCommand(const uint8_t * commandData, +ReturnValue_t PlocMPSoCHandler::prepareTcMemReadCommand(const uint8_t * commandData, size_t commandDataLen) { const uint32_t memoryAddress = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 | *(commandData + 3); packetSequenceCount = (packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK; - PLOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); - if (tcMemRead.getFullSize() > PLOC::MAX_COMMAND_SIZE) { - sif::debug << "PlocHandler::prepareTcMemReadCommand: Command too big" << std::endl; + PLOC_MPSOC::TcMemRead tcMemRead(memoryAddress, packetSequenceCount); + if (tcMemRead.getFullSize() > PLOC_MPSOC::MAX_COMMAND_SIZE) { + sif::debug << "PlocMPSoCHandler::prepareTcMemReadCommand: Command too big" << std::endl; return RETURN_FAILED; } memcpy(commandBuffer, tcMemRead.getWholeData(), tcMemRead.getFullSize()); rawPacket = commandBuffer; rawPacketLen = tcMemRead.getFullSize(); - nextReplyId = PLOC::ACK_REPORT; + nextReplyId = PLOC_MPSOC::ACK_REPORT; return RETURN_OK; } -ReturnValue_t PlocHandler::verifyPacket(const uint8_t* start, size_t foundLen) { +ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) { uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); @@ -199,17 +199,17 @@ ReturnValue_t PlocHandler::verifyPacket(const uint8_t* start, size_t foundLen) { return RETURN_OK; } -ReturnValue_t PlocHandler::handleAckReport(const uint8_t* data) { +ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC::SIZE_ACK_REPORT); + result = verifyPacket(data, PLOC_MPSOC::SIZE_ACK_REPORT); if(result == CRC_FAILURE) { - sif::error << "PlocHandler::handleAckReport: CRC failure" << std::endl; - nextReplyId = PLOC::NONE; - replyRawReplyIfnotWiretapped(data, PLOC::SIZE_ACK_REPORT); + sif::error << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_MPSOC::SIZE_ACK_REPORT); triggerEvent(CRC_FAILURE_EVENT); - sendFailureReport(PLOC::ACK_REPORT, CRC_FAILURE); + sendFailureReport(PLOC_MPSOC::ACK_REPORT, CRC_FAILURE); disableAllReplies(); return IGNORE_REPLY_DATA; } @@ -217,25 +217,25 @@ ReturnValue_t PlocHandler::handleAckReport(const uint8_t* data) { uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; switch(apid) { - case PLOC::APID_ACK_FAILURE: { + case PLOC_MPSOC::APID_ACK_FAILURE: { //TODO: Interpretation of status field in acknowledgment report - sif::debug << "PlocHandler::handleAckReport: Received Ack failure report" << std::endl; + sif::debug << "PlocMPSoCHandler::handleAckReport: Received Ack failure report" << std::endl; DeviceCommandId_t commandId = getPendingCommand(); if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(ACK_FAILURE, commandId); } - sendFailureReport(PLOC::ACK_REPORT, RECEIVED_ACK_FAILURE); + sendFailureReport(PLOC_MPSOC::ACK_REPORT, RECEIVED_ACK_FAILURE); disableAllReplies(); - nextReplyId = PLOC::NONE; + nextReplyId = PLOC_MPSOC::NONE; result = IGNORE_REPLY_DATA; break; } - case PLOC::APID_ACK_SUCCESS: { + case PLOC_MPSOC::APID_ACK_SUCCESS: { setNextReplyId(); break; } default: { - sif::debug << "PlocHandler::handleAckReport: Invalid APID in Ack report" << std::endl; + sif::debug << "PlocMPSoCHandler::handleAckReport: Invalid APID in Ack report" << std::endl; result = RETURN_FAILED; break; } @@ -244,71 +244,71 @@ ReturnValue_t PlocHandler::handleAckReport(const uint8_t* data) { return result; } -ReturnValue_t PlocHandler::handleExecutionReport(const uint8_t* data) { +ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC::SIZE_EXE_REPORT); + result = verifyPacket(data, PLOC_MPSOC::SIZE_EXE_REPORT); if(result == CRC_FAILURE) { - sif::error << "PlocHandler::handleExecutionReport: CRC failure" << std::endl; - nextReplyId = PLOC::NONE; + sif::error << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_MPSOC::NONE; return result; } uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; switch (apid) { - case (PLOC::APID_EXE_SUCCESS): { + case (PLOC_MPSOC::APID_EXE_SUCCESS): { break; } - case (PLOC::APID_EXE_FAILURE): { + case (PLOC_MPSOC::APID_EXE_FAILURE): { //TODO: Interpretation of status field in execution report - sif::error << "PlocHandler::handleExecutionReport: Received execution failure report" + sif::error << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" << std::endl; DeviceCommandId_t commandId = getPendingCommand(); if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { triggerEvent(EXE_FAILURE, commandId); } else { - sif::debug << "PlocHandler::handleExecutionReport: Unknown command id" << std::endl; + sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl; } - sendFailureReport(PLOC::EXE_REPORT, RECEIVED_EXE_FAILURE); + sendFailureReport(PLOC_MPSOC::EXE_REPORT, RECEIVED_EXE_FAILURE); disableExeReportReply(); result = IGNORE_REPLY_DATA; break; } default: { - sif::error << "PlocHandler::handleExecutionReport: Unknown APID" << std::endl; + sif::error << "PlocMPSoCHandler::handleExecutionReport: Unknown APID" << std::endl; result = RETURN_FAILED; break; } } - nextReplyId = PLOC::NONE; + nextReplyId = PLOC_MPSOC::NONE; return result; } -ReturnValue_t PlocHandler::handleMemoryReadReport(const uint8_t* data) { +ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { ReturnValue_t result = RETURN_OK; - result = verifyPacket(data, PLOC::SIZE_TM_MEM_READ_REPORT); + result = verifyPacket(data, PLOC_MPSOC::SIZE_TM_MEM_READ_REPORT); if(result == CRC_FAILURE) { - sif::error << "PlocHandler::handleMemoryReadReport: Memory read report has invalid crc" + sif::error << "PlocMPSoCHandler::handleMemoryReadReport: Memory read report has invalid crc" << std::endl; } /** Send data to commanding queue */ - handleDeviceTM(data + PLOC::DATA_FIELD_OFFSET, PLOC::SIZE_MEM_READ_REPORT_DATA, - PLOC::TM_MEMORY_READ_REPORT); + handleDeviceTM(data + PLOC_MPSOC::DATA_FIELD_OFFSET, PLOC_MPSOC::SIZE_MEM_READ_REPORT_DATA, + PLOC_MPSOC::TM_MEMORY_READ_REPORT); - nextReplyId = PLOC::EXE_REPORT; + nextReplyId = PLOC_MPSOC::EXE_REPORT; return result; } -ReturnValue_t PlocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, +ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, uint8_t expectedReplies, bool useAlternateId, DeviceCommandId_t alternateReplyID) { @@ -317,21 +317,21 @@ ReturnValue_t PlocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator comm uint8_t enabledReplies = 0; switch (command->first) { - case PLOC::TC_MEM_WRITE: + case PLOC_MPSOC::TC_MEM_WRITE: enabledReplies = 2; break; - case PLOC::TC_MEM_READ: { + case PLOC_MPSOC::TC_MEM_READ: { enabledReplies = 3; result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - PLOC::TM_MEMORY_READ_REPORT); + PLOC_MPSOC::TM_MEMORY_READ_REPORT); if (result != RETURN_OK) { - sif::debug << "PlocHandler::enableReplyInReplyMap: Reply with id " - << PLOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << PLOC_MPSOC::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; } break; } default: - sif::debug << "PlocHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl; break; } @@ -340,38 +340,38 @@ ReturnValue_t PlocHandler::enableReplyInReplyMap(DeviceCommandMap::iterator comm * replies will be enabled here. */ result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC::ACK_REPORT); + enabledReplies, true, PLOC_MPSOC::ACK_REPORT); if (result != RETURN_OK) { - sif::debug << "PlocHandler::enableReplyInReplyMap: Reply with id " << PLOC::ACK_REPORT + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::ACK_REPORT << " not in replyMap" << std::endl; } result = DeviceHandlerBase::enableReplyInReplyMap(command, - enabledReplies, true, PLOC::EXE_REPORT); + enabledReplies, true, PLOC_MPSOC::EXE_REPORT); if (result != RETURN_OK) { - sif::debug << "PlocHandler::enableReplyInReplyMap: Reply with id " << PLOC::EXE_REPORT + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << PLOC_MPSOC::EXE_REPORT << " not in replyMap" << std::endl; } return RETURN_OK; } -void PlocHandler::setNextReplyId() { +void PlocMPSoCHandler::setNextReplyId() { switch(getPendingCommand()) { - case PLOC::TC_MEM_READ: - nextReplyId = PLOC::TM_MEMORY_READ_REPORT; + case PLOC_MPSOC::TC_MEM_READ: + nextReplyId = PLOC_MPSOC::TM_MEMORY_READ_REPORT; break; default: /* If no telemetry is expected the next reply is always the execution report */ - nextReplyId = PLOC::EXE_REPORT; + nextReplyId = PLOC_MPSOC::EXE_REPORT; break; } } -size_t PlocHandler::getNextReplyLength(DeviceCommandId_t commandId){ +size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId){ size_t replyLen = 0; - if (nextReplyId == PLOC::NONE) { + if (nextReplyId == PLOC_MPSOC::NONE) { return replyLen; } @@ -384,14 +384,14 @@ size_t PlocHandler::getNextReplyLength(DeviceCommandId_t commandId){ replyLen = iter->second.replyLen; } else { - sif::debug << "PlocHandler::getNextReplyLength: No entry for reply with reply id " + sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id " << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; } return replyLen; } -void PlocHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { +void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { ReturnValue_t result = RETURN_OK; @@ -402,7 +402,7 @@ void PlocHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCom DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); if (iter == deviceReplyMap.end()) { - sif::debug << "PlocHandler::handleDeviceTM: Unknown reply id" << std::endl; + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Unknown reply id" << std::endl; return; } MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; @@ -413,16 +413,16 @@ void PlocHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCom result = actionHelper.reportData(queueId, replyId, data, dataSize); if (result != RETURN_OK) { - sif::debug << "PlocHandler::handleDeviceTM: Failed to report data" << std::endl; + sif::debug << "PlocMPSoCHandler::handleDeviceTM: Failed to report data" << std::endl; } } -void PlocHandler::disableAllReplies() { +void PlocMPSoCHandler::disableAllReplies() { DeviceReplyMap::iterator iter; /* Disable ack reply */ - iter = deviceReplyMap.find(PLOC::ACK_REPORT); + iter = deviceReplyMap.find(PLOC_MPSOC::ACK_REPORT); DeviceReplyInfo *info = &(iter->second); info->delayCycles = 0; info->command = deviceCommandMap.end(); @@ -431,17 +431,17 @@ void PlocHandler::disableAllReplies() { /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ switch (commandId) { - case PLOC::TC_MEM_WRITE: + case PLOC_MPSOC::TC_MEM_WRITE: break; - case PLOC::TC_MEM_READ: { - iter = deviceReplyMap.find(PLOC::TM_MEMORY_READ_REPORT); + case PLOC_MPSOC::TC_MEM_READ: { + iter = deviceReplyMap.find(PLOC_MPSOC::TM_MEMORY_READ_REPORT); info = &(iter->second); info->delayCycles = 0; info->command = deviceCommandMap.end(); break; } default: { - sif::debug << "PlocHandler::disableAllReplies: Unknown command id" << commandId + sif::debug << "PlocMPSoCHandler::disableAllReplies: Unknown command id" << commandId << std::endl; break; } @@ -451,19 +451,19 @@ void PlocHandler::disableAllReplies() { disableExeReportReply(); } -void PlocHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { +void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { DeviceReplyIter iter = deviceReplyMap.find(replyId); if (iter == deviceReplyMap.end()) { - sif::debug << "PlocHandler::sendFailureReport: Reply not in reply map" << std::endl; + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl; return; } DeviceCommandInfo* info = &(iter->second.command->second); if (info == nullptr) { - sif::debug << "PlocHandler::sendFailureReport: Reply has no active command" << std::endl; + sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply has no active command" << std::endl; return; } @@ -473,8 +473,8 @@ void PlocHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t sta info->isExecuting = false; } -void PlocHandler::disableExeReportReply() { - DeviceReplyIter iter = deviceReplyMap.find(PLOC::EXE_REPORT); +void PlocMPSoCHandler::disableExeReportReply() { + DeviceReplyIter iter = deviceReplyMap.find(PLOC_MPSOC::EXE_REPORT); DeviceReplyInfo *info = &(iter->second); info->delayCycles = 0; info->command = deviceCommandMap.end(); @@ -482,12 +482,12 @@ void PlocHandler::disableExeReportReply() { info->command->second.expectedReplies = 0; } -ReturnValue_t PlocHandler::checkPacketSequenceCount(const uint8_t* data) { +ReturnValue_t PlocMPSoCHandler::checkPacketSequenceCount(const uint8_t* data) { uint16_t receivedSequenceCount = (*(data + 2) << 8 | *(data + 3)) & PACKET_SEQUENCE_COUNT_MASK; uint16_t expectedPacketSequenceCount = ((packetSequenceCount + 1) & PACKET_SEQUENCE_COUNT_MASK); if (receivedSequenceCount != expectedPacketSequenceCount) { sif::debug - << "PlocHandler::checkPacketSequenceCount: Packet sequence count mismatch. " + << "PlocMPSoCHandler::checkPacketSequenceCount: Packet sequence count mismatch. " << std::endl; sif::debug << "Received sequence count: " << receivedSequenceCount << ". OBSW sequence " << "count: " << expectedPacketSequenceCount << std::endl; diff --git a/mission/devices/PlocHandler.h b/mission/devices/PlocMPSoCHandler.h similarity index 89% rename from mission/devices/PlocHandler.h rename to mission/devices/PlocMPSoCHandler.h index d400318e..2b3f6a57 100644 --- a/mission/devices/PlocHandler.h +++ b/mission/devices/PlocMPSoCHandler.h @@ -1,25 +1,28 @@ -#ifndef MISSION_DEVICES_PLOCHANDLER_H_ -#define MISSION_DEVICES_PLOCHANDLER_H_ +#ifndef MISSION_DEVICES_PLOCMPSOCHANDLER_H_ +#define MISSION_DEVICES_PLOCMPSOCHANDLER_H_ #include -#include +#include #include /** - * @brief This is the device handler for the PLOC. + * @brief This is the device handler for the MPSoC which is programmed by the ILH of the + * university of stuttgart. * * @details * The PLOC uses the space packet protocol for communication. To each command the PLOC * answers with at least one acknowledgment and one execution report. * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_Commands + * ILH ICD: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/ + * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * @author J. Meier */ -class PlocHandler: public DeviceHandlerBase { +class PlocMPSoCHandler: public DeviceHandlerBase { public: - PlocHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); - virtual ~PlocHandler(); + PlocMPSoCHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); + virtual ~PlocMPSoCHandler(); /** * @brief Sets mode to MODE_NORMAL. Can be used for debugging. @@ -49,14 +52,14 @@ protected: private: - static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_HANDLER; + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER; static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); //!> Space Packet received from PLOC has invalid CRC static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); //!> Received ACK failure reply from PLOC static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); //!> Received execution failure reply from PLOC static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); //!> Received space packet with invalid APID from PLOC - static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_HANDLER; + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); //!> PLOC crc failure in telemetry packet static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW); //!> PLOC receive acknowledgment failure report @@ -66,7 +69,7 @@ private: static const uint16_t APID_MASK = 0x7FF; static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; - uint8_t commandBuffer[PLOC::MAX_COMMAND_SIZE]; + uint8_t commandBuffer[PLOC_MPSOC::MAX_COMMAND_SIZE]; /** * @brief This object is incremented each time a packet is sent or received. By checking the @@ -85,7 +88,7 @@ private: * because the PLOC sends as reply to each command at least one acknowledgment and execution * report. */ - DeviceCommandId_t nextReplyId = PLOC::NONE; + DeviceCommandId_t nextReplyId = PLOC_MPSOC::NONE; /** * @brief This function fills the commandBuffer to initiate the write memory command. @@ -200,4 +203,4 @@ private: ReturnValue_t checkPacketSequenceCount(const uint8_t* data); }; -#endif /* MISSION_DEVICES_PLOCHANDLER_H_ */ +#endif /* MISSION_DEVICES_PLOCMPSOCHANDLER_H_ */ diff --git a/mission/devices/PlocSupervisorHandler.cpp b/mission/devices/PlocSupervisorHandler.cpp new file mode 100644 index 00000000..351a0cd9 --- /dev/null +++ b/mission/devices/PlocSupervisorHandler.cpp @@ -0,0 +1,581 @@ +#include "PlocSupervisorHandler.h" +#include "OBSWConfig.h" + +#include +#include +#include + +PlocSupervisorHandler::PlocSupervisorHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie) : + DeviceHandlerBase(objectId, comIF, comCookie), hkset(this) { + if (comCookie == NULL) { + sif::error << "PlocSupervisorHandler: Invalid com cookie" << std::endl; + } +} + +PlocSupervisorHandler::~PlocSupervisorHandler() { +} + + +void PlocSupervisorHandler::doStartUp(){ +#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 + setMode(MODE_NORMAL); +#else + setMode(_MODE_TO_ON); +#endif +} + +void PlocSupervisorHandler::doShutDown(){ + +} + +ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand( + DeviceCommandId_t * id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand( + DeviceCommandId_t * id){ + return NOTHING_TO_SEND; +} + +ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand( + DeviceCommandId_t deviceCommand, const uint8_t * commandData, + size_t commandDataLen) { + switch(deviceCommand) { + case(PLOC_SPV::GET_HK_REPORT): { + prepareEmptyCmd(PLOC_SPV::APID_GET_HK_REPORT); + return RETURN_OK; + } + case(PLOC_SPV::RESTART_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_RESTART_MPSOC); + return RETURN_OK; + } + case(PLOC_SPV::START_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_START_MPSOC); + return RETURN_OK; + } + case(PLOC_SPV::SHUTDOWN_MPSOC): { + prepareEmptyCmd(PLOC_SPV::APID_SHUTWOWN_MPSOC); + return RETURN_OK; + } + case(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE): { + prepareSelBootImageCmd(commandData); + return RETURN_OK; + } + case(PLOC_SPV::SET_TIME_REF): { + return prepareSetTimeRefCmd(); + } + case(PLOC_SPV::SET_BOOT_TIMEOUT): { + prepareSetBootTimeoutCmd(commandData); + return RETURN_OK; + } + default: + sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" + << std::endl; + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + return HasReturnvaluesIF::RETURN_FAILED; +} + +void PlocSupervisorHandler::fillCommandAndReplyMap() { + this->insertInCommandMap(PLOC_SPV::GET_HK_REPORT); + this->insertInCommandMap(PLOC_SPV::RESTART_MPSOC); + this->insertInCommandMap(PLOC_SPV::START_MPSOC); + this->insertInCommandMap(PLOC_SPV::SHUTDOWN_MPSOC); + this->insertInCommandMap(PLOC_SPV::SEL_MPSOC_BOOT_IMAGE); + this->insertInCommandMap(PLOC_SPV::SET_BOOT_TIMEOUT); + this->insertInCommandMap(PLOC_SPV::SET_MAX_RESTART_TRIES); + this->insertInCommandMap(PLOC_SPV::RESET_MPSOC); + this->insertInCommandMap(PLOC_SPV::SET_TIME_REF); + this->insertInReplyMap(PLOC_SPV::ACK_REPORT, 3, nullptr, PLOC_SPV::SIZE_ACK_REPORT); + this->insertInReplyMap(PLOC_SPV::EXE_REPORT, 3, nullptr, PLOC_SPV::SIZE_EXE_REPORT); + this->insertInReplyMap(PLOC_SPV::HK_REPORT, 3, nullptr, PLOC_SPV::SIZE_HK_REPORT); +} + +ReturnValue_t PlocSupervisorHandler::scanForReply(const uint8_t *start, + size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) { + + ReturnValue_t result = RETURN_OK; + + uint16_t apid = (*(start) << 8 | *(start + 1)) & APID_MASK; + + switch(apid) { + case(PLOC_SPV::APID_ACK_SUCCESS): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case(PLOC_SPV::APID_ACK_FAILURE): + *foundLen = PLOC_SPV::SIZE_ACK_REPORT; + *foundId = PLOC_SPV::ACK_REPORT; + break; + case(PLOC_SPV::APID_HK_REPORT): + *foundLen = PLOC_SPV::SIZE_HK_REPORT; + *foundId = PLOC_SPV::HK_REPORT; + break; + case(PLOC_SPV::APID_EXE_SUCCESS): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + case(PLOC_SPV::APID_EXE_FAILURE): + *foundLen = PLOC_SPV::SIZE_EXE_REPORT; + *foundId = PLOC_SPV::EXE_REPORT; + break; + default: { + sif::debug << "PlocSupervisorHandler::scanForReply: Reply has invalid apid" << std::endl; + *foundLen = remainingSize; + return INVALID_APID; + } + } + + return result; +} + +ReturnValue_t PlocSupervisorHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + + ReturnValue_t result = RETURN_OK; + + switch (id) { + case PLOC_SPV::ACK_REPORT: { + result = handleAckReport(packet); + break; + } + case (PLOC_SPV::HK_REPORT): { + result = handleHkReport(packet); + break; + } + case (PLOC_SPV::EXE_REPORT): { + result = handleExecutionReport(packet); + break; + } + default: { + sif::debug << "PlocSupervisorHandler::interpretDeviceReply: Unknown device reply id" << std::endl; + return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; + } + } + + return result; +} + +void PlocSupervisorHandler::setNormalDatapoolEntriesInvalid(){ + +} + +uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo){ + return 500; +} + +ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { + + localDataPoolMap.emplace(PLOC_SPV::NUM_TMS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::TEMP_PL, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::SOC_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::NVM0_1_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::NVM3_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::MISSION_IO_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::FMC_STATE, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::NUM_TCS, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::UPTIME, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::CPULOAD, new PoolEntry( { 0 })); + localDataPoolMap.emplace(PLOC_SPV::AVAILABLEHEAP, new PoolEntry( { 0 })); + + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PlocSupervisorHandler::verifyPacket(const uint8_t* start, size_t foundLen) { + + uint16_t receivedCrc = *(start + foundLen - 2) << 8 | *(start + foundLen - 1); + + uint16_t recalculatedCrc = CRC::crc16ccitt(start, foundLen - 2); + + if (receivedCrc != recalculatedCrc) { + return CRC_FAILURE; + } + + return RETURN_OK; +} + +ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) { + + ReturnValue_t result = RETURN_OK; + + result = verifyPacket(data, PLOC_SPV::SIZE_ACK_REPORT); + if(result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleAckReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + replyRawReplyIfnotWiretapped(data, PLOC_SPV::SIZE_ACK_REPORT); + triggerEvent(SUPV_CRC_FAILURE_EVENT); + sendFailureReport(PLOC_SPV::ACK_REPORT, CRC_FAILURE); + disableAllReplies(); + return IGNORE_REPLY_DATA; + } + + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch(apid) { + case PLOC_SPV::APID_ACK_FAILURE: { + //TODO: Interpretation of status field in acknowledgment report + sif::debug << "PlocSupervisorHandler::handleAckReport: Received Ack failure report" << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_ACK_FAILURE, commandId); + } + sendFailureReport(PLOC_SPV::ACK_REPORT, RECEIVED_ACK_FAILURE); + disableAllReplies(); + nextReplyId = PLOC_SPV::NONE; + result = IGNORE_REPLY_DATA; + break; + } + case PLOC_SPV::APID_ACK_SUCCESS: { + setNextReplyId(); + break; + } + default: { + sif::debug << "PlocSupervisorHandler::handleAckReport: Invalid APID in Ack report" << std::endl; + result = RETURN_FAILED; + break; + } + } + + return result; +} + +ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data) { + + ReturnValue_t result = RETURN_OK; + + result = verifyPacket(data, PLOC_SPV::SIZE_EXE_REPORT); + if(result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleExecutionReport: CRC failure" << std::endl; + nextReplyId = PLOC_SPV::NONE; + return result; + } + + uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + + switch (apid) { + case (PLOC_SPV::APID_EXE_SUCCESS): { + break; + } + case (PLOC_SPV::APID_EXE_FAILURE): { + //TODO: Interpretation of status field in execution report + sif::error << "PlocSupervisorHandler::handleExecutionReport: Received execution failure report" + << std::endl; + DeviceCommandId_t commandId = getPendingCommand(); + if (commandId != DeviceHandlerIF::NO_COMMAND_ID) { + triggerEvent(SUPV_EXE_FAILURE, commandId); + } + else { + sif::debug << "PlocSupervisorHandler::handleExecutionReport: Unknown command id" << std::endl; + } + sendFailureReport(PLOC_SPV::EXE_REPORT, RECEIVED_EXE_FAILURE); + disableExeReportReply(); + result = IGNORE_REPLY_DATA; + break; + } + default: { + sif::error << "PlocSupervisorHandler::handleExecutionReport: Unknown APID" << std::endl; + result = RETURN_FAILED; + break; + } + } + + nextReplyId = PLOC_SPV::NONE; + + return result; +} + +ReturnValue_t PlocSupervisorHandler::handleHkReport(const uint8_t* data) { + + ReturnValue_t result = RETURN_OK; + + result = verifyPacket(data, PLOC_SPV::SIZE_HK_REPORT); + + if(result == CRC_FAILURE) { + sif::error << "PlocSupervisorHandler::handleHkReport: Hk report has invalid crc" + << std::endl; + } + + uint16_t offset = PLOC_SPV::DATA_FIELD_OFFSET; + hkset.numTms = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.tempPs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.tempPl = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.socState = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.nvm0_1_state = *(data + offset); + offset += 1; + hkset.nvm3_state = *(data + offset); + offset += 1; + hkset.missionIoState = *(data + offset); + offset += 1; + hkset.fmcState = *(data + offset); + offset += 1; + hkset.numTcs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.tempSup = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.uptime = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.cpuLoad = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + hkset.availableHeap = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 + | *(data + offset + 3); + offset += 4; + + nextReplyId = PLOC_SPV::EXE_REPORT; + +#if OBSW_VERBOSE_LEVEL >= 1 && PLOC_MPSOC_DEBUG == 1 + sif::info << "PlocSupervisorHandler::handleHkReport: num_tms: " << hkset.numTms << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_ps: " << hkset.tempPs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_pl: " << hkset.tempPl << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: soc_state: " << hkset.socState << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: nvm0_1_state: " + << static_cast(hkset.nvm0_1_state.value) << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: nvm3_state: " + << static_cast(hkset.nvm3_state.value) << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: missoin_io_state: " + << static_cast(hkset.missionIoState.value) << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: fmc_state: " + << static_cast(hkset.fmcState.value) << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: num_tcs: " << hkset.numTcs << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: temp_sup: " << hkset.tempSup << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: uptime: " << hkset.uptime << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: cpu_load: " << hkset.cpuLoad << std::endl; + sif::info << "PlocSupervisorHandler::handleHkReport: available_heap: " << hkset.availableHeap << std::endl; +#endif + + return result; +} + +ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::iterator command, + uint8_t expectedReplies, bool useAlternateId, + DeviceCommandId_t alternateReplyID) { + + ReturnValue_t result = RETURN_OK; + + uint8_t enabledReplies = 0; + + switch (command->first) { + case PLOC_SPV::GET_HK_REPORT: { + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::HK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::HK_REPORT << " not in replyMap" << std::endl; + } + break; + } + case PLOC_SPV::RESTART_MPSOC: + case PLOC_SPV::START_MPSOC: + case PLOC_SPV::SHUTDOWN_MPSOC: + case PLOC_SPV::SEL_MPSOC_BOOT_IMAGE: + case PLOC_SPV::SET_BOOT_TIMEOUT: + case PLOC_SPV::SET_MAX_RESTART_TRIES: + case PLOC_SPV::RESET_MPSOC: + case PLOC_SPV::SET_TIME_REF: + enabledReplies = 2; + break; + default: + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Unknown command id" << std::endl; + break; + } + + /** + * Every command causes at least one acknowledgment and one execution report. Therefore both + * replies will be enabled here. + */ + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::ACK_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::ACK_REPORT << " not in replyMap" << std::endl; + } + + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, + PLOC_SPV::EXE_REPORT); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::enableReplyInReplyMap: Reply with id " + << PLOC_SPV::EXE_REPORT << " not in replyMap" << std::endl; + } + + return RETURN_OK; +} + +void PlocSupervisorHandler::setNextReplyId() { + switch(getPendingCommand()) { + case PLOC_SPV::GET_HK_REPORT: + nextReplyId = PLOC_SPV::HK_REPORT; + break; + default: + /* If no telemetry is expected the next reply is always the execution report */ + nextReplyId = PLOC_SPV::EXE_REPORT; + break; + } +} +size_t PlocSupervisorHandler::getNextReplyLength(DeviceCommandId_t commandId){ + + size_t replyLen = 0; + + if (nextReplyId == PLOC_SPV::NONE) { + return replyLen; + } + + DeviceReplyIter iter = deviceReplyMap.find(nextReplyId); + if (iter != deviceReplyMap.end()) { + if (iter->second.delayCycles == 0) { + /* Reply inactive */ + return replyLen; + } + replyLen = iter->second.replyLen; + } + else { + sif::debug << "PlocSupervisorHandler::getNextReplyLength: No entry for reply with reply id " + << std::hex << nextReplyId << " in deviceReplyMap" << std::endl; + } + + return replyLen; +} + +void PlocSupervisorHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { + + ReturnValue_t result = RETURN_OK; + + if (wiretappingMode == RAW) { + /* Data already sent in doGetRead() */ + return; + } + + DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Unknown reply id" << std::endl; + return; + } + MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; + + if (queueId == NO_COMMANDER) { + return; + } + + result = actionHelper.reportData(queueId, replyId, data, dataSize); + if (result != RETURN_OK) { + sif::debug << "PlocSupervisorHandler::handleDeviceTM: Failed to report data" << std::endl; + } +} + +void PlocSupervisorHandler::prepareEmptyCmd(uint16_t apid) { + PLOC_SPV::EmptyPacket packet(apid); + memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = packet.getFullSize(); + nextReplyId = PLOC_SPV::ACK_REPORT; +} + +void PlocSupervisorHandler::prepareSelBootImageCmd(const uint8_t * commandData) { + PLOC_SPV::MPSoCBootSelect packet(*commandData, *(commandData + 1), *(commandData + 2), + *(commandData + 3)); + memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = packet.getFullSize(); + nextReplyId = PLOC_SPV::ACK_REPORT; +} + +ReturnValue_t PlocSupervisorHandler::prepareSetTimeRefCmd() { + Clock::TimeOfDay_t time; + ReturnValue_t result = Clock::getDateAndTime(&time); + if (result != RETURN_OK) { + sif::warning << "PlocSupervisorHandler::prepareSetTimeRefCmd: Failed to get current time" + << std::endl; + return GET_TIME_FAILURE; + } + PLOC_SPV::SetTimeRef packet(&time); + memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = packet.getFullSize(); + nextReplyId = PLOC_SPV::ACK_REPORT; + return RETURN_OK; +} + +void PlocSupervisorHandler::prepareSetBootTimeoutCmd(const uint8_t * commandData) { + uint32_t timeout = *(commandData) << 24 | *(commandData + 1) << 16 | *(commandData + 2) << 8 + | *(commandData + 3); + PLOC_SPV::SetBootTimeout packet(timeout); + memcpy(commandBuffer, packet.getWholeData(), packet.getFullSize()); + rawPacket = commandBuffer; + rawPacketLen = packet.getFullSize(); + nextReplyId = PLOC_SPV::ACK_REPORT; +} + +void PlocSupervisorHandler::disableAllReplies() { + + DeviceReplyMap::iterator iter; + + /* Disable ack reply */ + iter = deviceReplyMap.find(PLOC_SPV::ACK_REPORT); + DeviceReplyInfo *info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + + DeviceCommandId_t commandId = getPendingCommand(); + + /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ + switch (commandId) { + case PLOC_SPV::HK_REPORT: { + iter = deviceReplyMap.find(PLOC_SPV::HK_REPORT); + info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + break; + } + default: { + break; + } + } + + /* We must always disable the execution report reply here */ + disableExeReportReply(); +} + +void PlocSupervisorHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) { + + DeviceReplyIter iter = deviceReplyMap.find(replyId); + + if (iter == deviceReplyMap.end()) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply not in reply map" << std::endl; + return; + } + + DeviceCommandInfo* info = &(iter->second.command->second); + + if (info == nullptr) { + sif::debug << "PlocSupervisorHandler::sendFailureReport: Reply has no active command" << std::endl; + return; + } + + if (info->sendReplyTo != NO_COMMANDER) { + actionHelper.finish(false, info->sendReplyTo, iter->first, status); + } + info->isExecuting = false; +} + +void PlocSupervisorHandler::disableExeReportReply() { + DeviceReplyIter iter = deviceReplyMap.find(PLOC_SPV::EXE_REPORT); + DeviceReplyInfo *info = &(iter->second); + info->delayCycles = 0; + info->command = deviceCommandMap.end(); + /* Expected replies is set to one here. The value will set to 0 in replyToReply() */ + info->command->second.expectedReplies = 0; +} diff --git a/mission/devices/PlocSupervisorHandler.h b/mission/devices/PlocSupervisorHandler.h new file mode 100644 index 00000000..fcbc5a50 --- /dev/null +++ b/mission/devices/PlocSupervisorHandler.h @@ -0,0 +1,202 @@ +#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ +#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ + +#include +#include +#include + +/** + * @brief This is the device handler for the supervisor of the PLOC which is programmed by + * Thales. + * + * @details The PLOC uses the space packet protocol for communication. To each command the PLOC + * answers with at least one acknowledgment and one execution report. + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_Commands + * ILH ICD: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/ + * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 + * @author J. Meier + */ +class PlocSupervisorHandler: public DeviceHandlerBase { +public: + + PlocSupervisorHandler(object_id_t objectId, object_id_t comIF, CookieIF * comCookie); + virtual ~PlocSupervisorHandler(); + +protected: + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override; + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override; + void fillCommandAndReplyMap() override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t * commandData,size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, + DeviceCommandId_t *foundId, size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) override; + void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command, + uint8_t expectedReplies = 1, bool useAlternateId = false, + DeviceCommandId_t alternateReplyID = 0) override; + size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; + +private: + + static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; + + //! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor + static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor + static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor + static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Failed to read current system time + static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4); + + static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER; + + //! [EXPORT] : [COMMENT] PLOC supervrisor crc failure in telemetry packet + static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); + //! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report + static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW); + //! [EXPORT] : [COMMENT] PLOC received execution failure report + static const Event SUPV_EXE_FAILURE = MAKE_EVENT(3, severity::LOW); + //! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc + static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW); + + static const uint16_t APID_MASK = 0x7FF; + static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; + + uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; + + /** + * @brief This object is incremented each time a packet is sent or received. By checking the + * packet sequence count of a received packet, no packets can be lost without noticing + * it. Only the least significant 14 bits represent the packet sequence count in a + * space packet. Thus the maximum value amounts to 16383 (0x3FFF). + * @note Normally this should never happen because the PLOC replies are always sent in a + * fixed order. However, the PLOC software checks this value and will return an ACK + * failure report in case the sequence count is not incremented with each transferred + * space packet. + */ + uint16_t packetSequenceCount = 0x3FFF; + + /** + * This variable is used to store the id of the next reply to receive. This is necessary + * because the PLOC sends as reply to each command at least one acknowledgment and execution + * report. + */ + DeviceCommandId_t nextReplyId = PLOC_SPV::NONE; + + PLOC_SPV::HkSet hkset; + + /** + * @brief This function checks the crc of the received PLOC reply. + * + * @param start Pointer to the first byte of the reply. + * @param foundLen Pointer to the length of the whole packet. + * + * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. + */ + ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); + + /** + * @brief This function handles the acknowledgment report. + * + * @param data Pointer to the data holding the acknowledgment report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleAckReport(const uint8_t* data); + + /** + * @brief This function handles the data of a execution report. + * + * @param data Pointer to the received data packet. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleExecutionReport(const uint8_t* data); + + /** + * @brief This function handles the housekeeping report. This means verifying the CRC of the + * reply and filling the appropriate dataset. + * + * @param data Pointer to the data buffer holding the housekeeping read report. + * + * @return RETURN_OK if successful, otherwise an error code. + */ + ReturnValue_t handleHkReport(const uint8_t* data); + + /** + * @brief Depending on the current active command, this function sets the reply id of the + * next reply after a successful acknowledgment report has been received. This is + * required by the function getNextReplyLength() to identify the length of the next + * reply to read. + */ + void setNextReplyId(); + + /** + * @brief This function handles action message replies in case the telemetry has been + * requested by another object. + * + * @param data Pointer to the telemetry data. + * @param dataSize Size of telemetry in bytes. + * @param replyId Id of the reply. This will be added to the ActionMessage. + */ + void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + + /** + * @brief This function prepares a space packet which does not transport any data in the + * packet data field apart from the crc. + */ + void prepareEmptyCmd(uint16_t apid); + + + /** + * @brief This function initializes the space packet to select the boot image of the MPSoC. + */ + void prepareSelBootImageCmd(const uint8_t * commandData); + + /** + * @brief This function fills the commandBuffer with the data to update the time of the + * PLOC supervisor. + */ + ReturnValue_t prepareSetTimeRefCmd(); + + /** + * @brief This function fills the commandBuffer with the data to change the boot timeout + * value in the PLOC supervisor. + */ + void prepareSetBootTimeoutCmd(const uint8_t * commandData); + + /** + * @brief In case an acknowledgment failure reply has been received this function disables + * all previously enabled commands and resets the exepected replies variable of an + * active command. + */ + void disableAllReplies(); + + /** + * @brief This function sends a failure report if the active action was commanded by an other + * object. + * + * @param replyId The id of the reply which signals a failure. + * @param status A status byte which gives information about the failure type. + */ + void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status); + + /** + * @brief This function disables the execution report reply. Within this function also the + * the variable expectedReplies of an active command will be set to 0. + */ + void disableExeReportReply(); +}; + +#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ diff --git a/mission/devices/RadiationSensorHandler.cpp b/mission/devices/RadiationSensorHandler.cpp index 102f941e..bb5176ee 100644 --- a/mission/devices/RadiationSensorHandler.cpp +++ b/mission/devices/RadiationSensorHandler.cpp @@ -77,22 +77,26 @@ ReturnValue_t RadiationSensorHandler::buildCommandFromCommand( case(RAD_SENSOR::START_CONVERSION): { /* First the fifo will be reset here */ cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; - cmdBuffer[0] = RAD_SENSOR::CONVERSION_DEFINITION; + cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; rawPacket = cmdBuffer; rawPacketLen = 2; return RETURN_OK; } case(RAD_SENSOR::READ_CONVERSIONS): { cmdBuffer[0] = RAD_SENSOR::DUMMY_BYTE; - cmdBuffer[1] = RAD_SENSOR::DUMMY_BYTE; - cmdBuffer[2] = RAD_SENSOR::DUMMY_BYTE; - cmdBuffer[3] = RAD_SENSOR::DUMMY_BYTE; - cmdBuffer[4] = RAD_SENSOR::DUMMY_BYTE; - cmdBuffer[5] = RAD_SENSOR::DUMMY_BYTE; + std::memset(cmdBuffer, RAD_SENSOR::DUMMY_BYTE, RAD_SENSOR::READ_SIZE); rawPacket = cmdBuffer; rawPacketLen = RAD_SENSOR::READ_SIZE; return RETURN_OK; } +// case(RAD_SENSOR::AIN0_AND_TMP_CONVERSION): { +// /* First the fifo will be reset here */ +// cmdBuffer[0] = RAD_SENSOR::RESET_DEFINITION; +// cmdBuffer[1] = RAD_SENSOR::CONVERSION_DEFINITION; +// rawPacket = cmdBuffer; +// rawPacketLen = 2; +// return RETURN_OK; +// } default: return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } @@ -127,16 +131,36 @@ ReturnValue_t RadiationSensorHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { switch (id) { case RAD_SENSOR::READ_CONVERSIONS: { + uint8_t offset = 0; PoolReadGuard readSet(&dataset); - dataset.temperatureCelcius = (*(packet) << 8 | *(packet + 1)) * 0.125; - dataset.channel0 = (*(packet + 2) << 8 | *(packet + 3)); - dataset.channel1 = (*(packet + 4) << 8 | *(packet + 5)); + dataset.temperatureCelcius = (*(packet + offset) << 8 | *(packet + offset + 1)) * 0.125; + offset += 2; + dataset.ain0 = (*(packet + offset) << 8 | *(packet + offset +1)); + offset += 2; + dataset.ain1 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 6; + dataset.ain4 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain5 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain6 = (*(packet + offset) << 8 | *(packet + offset + 1)); + offset += 2; + dataset.ain7 = (*(packet + offset) << 8 | *(packet + offset + 1)); + #if OBSW_VERBOSE_LEVEL >= 1 && DEBUG_RAD_SENSOR sif::info << "Radiation sensor temperature: " << dataset.temperatureCelcius << " °C" << std::endl; - sif::info << "Radiation sensor temperature ADC value channel 0: " << dataset.channel0 + sif::info << "Radiation sensor ADC value channel 0: " << dataset.ain0 << std::endl; - sif::info << "Radiation sensor temperature ADC value channel 1: " << dataset.channel1 + sif::info << "Radiation sensor ADC value channel 1: " << dataset.ain1 + << std::endl; + sif::info << "Radiation sensor ADC value channel 4: " << dataset.ain4 + << std::endl; + sif::info << "Radiation sensor ADC value channel 5: " << dataset.ain5 + << std::endl; + sif::info << "Radiation sensor ADC value channel 6: " << dataset.ain6 + << std::endl; + sif::info << "Radiation sensor ADC value channel 7: " << dataset.ain7 << std::endl; #endif break; @@ -161,8 +185,12 @@ uint32_t RadiationSensorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t mo ReturnValue_t RadiationSensorHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { localDataPoolMap.emplace(RAD_SENSOR::TEMPERATURE_C, new PoolEntry( { 0.0 })); - localDataPoolMap.emplace(RAD_SENSOR::CHANNEL_0, new PoolEntry( { 0 })); - localDataPoolMap.emplace(RAD_SENSOR::CHANNEL_1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RAD_SENSOR::AIN0, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RAD_SENSOR::AIN1, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RAD_SENSOR::AIN4, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RAD_SENSOR::AIN5, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RAD_SENSOR::AIN6, new PoolEntry( { 0 })); + localDataPoolMap.emplace(RAD_SENSOR::AIN7, new PoolEntry( { 0 })); return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/devicedefinitions/PlocDefinitions.h b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h similarity index 96% rename from mission/devices/devicedefinitions/PlocDefinitions.h rename to mission/devices/devicedefinitions/PlocMPSoCDefinitions.h index 5cc38d5a..2b9466ab 100644 --- a/mission/devices/devicedefinitions/PlocDefinitions.h +++ b/mission/devices/devicedefinitions/PlocMPSoCDefinitions.h @@ -1,11 +1,11 @@ -#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCDEFINITIONS_H_ -#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCDEFINITIONS_H_ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #include #include #include -namespace PLOC { +namespace PLOC_MPSOC { static const DeviceCommandId_t NONE = 0x0; static const DeviceCommandId_t TC_MEM_WRITE = 0x1; @@ -169,4 +169,4 @@ namespace PLOC { } -#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCDEFINITIONS_H_ */ +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/PlocSupervisorDefinitions.h b/mission/devices/devicedefinitions/PlocSupervisorDefinitions.h new file mode 100644 index 00000000..8fffff79 --- /dev/null +++ b/mission/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -0,0 +1,324 @@ +#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ +#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ + +#include +#include +#include +#include + +namespace PLOC_SPV { + +/** Command IDs */ +static const DeviceCommandId_t NONE = 0; +static const DeviceCommandId_t GET_HK_REPORT = 1; +static const DeviceCommandId_t RESTART_MPSOC = 2; +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; + +/** Reply IDs */ +static const DeviceCommandId_t ACK_REPORT = 50; +static const DeviceCommandId_t EXE_REPORT = 51; +static const DeviceCommandId_t HK_REPORT = 52; + +static const uint16_t SIZE_ACK_REPORT = 14; +static const uint16_t SIZE_EXE_REPORT = 14; +static const uint16_t SIZE_HK_REPORT = 48; + +/** + * SpacePacket apids of telemetry packets + */ +static const uint16_t APID_ACK_SUCCESS = 0x200; +static const uint16_t APID_ACK_FAILURE = 0x201; +static const uint16_t APID_EXE_SUCCESS = 0x202; +static const uint16_t APID_EXE_FAILURE = 0x203; +static const uint16_t APID_HK_REPORT = 0x204; +static const uint16_t APID_BOOT_STATUS_REPORT = 0x205; +static const uint16_t APID_UPDATE_STATUS_REPORT = 0x206; +static const uint16_t APID_WDG_STATUS_REPORT = 0x207; +static const uint16_t APID_LATCHUP_STATUS_REPORT = 0x208; +static const uint16_t APID_SOC_SYSMON = 0x209; +static const uint16_t APID_MRAM = 0x20A; +static const uint16_t APID_SRAM = 0x20B; +static const uint16_t APID_NOR_DATA = 0x20C; +static const uint16_t APID_DATA_LOGGER_DATA = 0x20D; + +/** + * APIDs of telecommand packets + */ +static const uint16_t APID_RESTART_MPSOC = 0xA0; +static const uint16_t APID_START_MPSOC = 0xA1; +static const uint16_t APID_SHUTWOWN_MPSOC = 0xA2; +static const uint16_t APID_SEL_MPSOC_BOOT_IMAGE = 0xA3; +static const uint16_t APID_SET_BOOT_TIMEOUT = 0xA4; +static const uint16_t APID_SET_MAX_RESTART_TRIES = 0xA5; +static const uint16_t APID_RESET_MPSOC = 0xA6; +static const uint16_t APID_GET_BOOT_STATUS_RPT = 0xA8; +static const uint16_t APID_UPDATE_AVAILABLE = 0xB0; +static const uint16_t APID_UPDATE_IMAGE_DATA = 0xB1; +static const uint16_t APID_UPDATE_VERIFY = 0xB2; +static const uint16_t APID_WTD_ENABLE = 0xC0; +static const uint16_t APID_WTD_CONFIG_TIMEOUT = 0xC1; +static const uint16_t APID_SET_TIME_REF = 0xC2; + +static const uint16_t APID_GET_HK_REPORT = 0xC6; + +/** Offset from first byte in Space packet to first byte of data field */ +static const uint8_t DATA_FIELD_OFFSET = 6; + +/** + * Space packet length for fixed size packets. This is the size of the whole packet data + * field. For the length field in the space packet this size will be substracted by one. + */ +static const uint16_t LENGTH_EMPTY_TC = 2; // Only CRC will be transported with the data field + +/** This is the maximum length of a space packet as defined by the TAS ICD */ +static const size_t MAX_REPLY_SIZE = 1024; +static const size_t MAX_COMMAND_SIZE = 1024; + +enum SequenceFlags { + CONTINUED_PKT = 0b00, FIRST_PKT = 0b01, LAST_PKT = 0b10, STANDALONE_PKT = 0b11 +}; + +enum PoolIds + : lp_id_t { + NUM_TMS, + TEMP_PS, + TEMP_PL, + SOC_STATE, + NVM0_1_STATE, + NVM3_STATE, + MISSION_IO_STATE, + FMC_STATE, + NUM_TCS, + TEMP_SUP, + UPTIME, + CPULOAD, + AVAILABLEHEAP +}; + +static const uint8_t HK_SET_ENTRIES = 13; + +static const uint32_t HK_SET_ID = HK_REPORT; + +/** + * @brief With this class a space packet can be created which does not contain any data. + */ +class EmptyPacket: public SpacePacket { +public: + + /** + * @brief Constructor + * + * @param apid The APID to set in the space packet. + * + * @note Sequence count of empty packet is always 1. + */ + EmptyPacket(uint16_t apid) : + SpacePacket(LENGTH_EMPTY_TC - 1, true, apid, 1) { + calcCrc(); + } + +private: + + /** + * @brief CRC calculation which involves only the header in an empty packet + */ + void calcCrc() { + + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader)); + + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } +}; + +/** + * @brief This class can be used to generate the space packet selecting the boot image of + * of the MPSoC. + */ +class MPSoCBootSelect: public SpacePacket { +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 + */ + MPSoCBootSelect(uint8_t mem, uint8_t bp0, uint8_t bp1, uint8_t bp2) : + SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SEL_MPSOC_BOOT_IMAGE, + DEFAULT_SEQUENCE_COUNT), mem(mem), bp0(bp0), bp1(bp1), bp2(bp2) { + initPacket(); + } + +private: + + static const uint16_t DATA_FIELD_LENGTH = 6; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + + static const uint8_t MEM_OFFSET = 0; + static const uint8_t BP0_OFFSET = 1; + static const uint8_t BP1_OFFSET = 2; + static const uint8_t BP2_OFFSET = 3; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + + uint8_t mem = 0; + uint8_t bp0 = 0; + uint8_t bp1 = 0; + uint8_t bp2 = 0; + + void initPacket() { + uint8_t* data_field_start = this->localData.fields.buffer; + std::memcpy(data_field_start + MEM_OFFSET, &mem, sizeof(mem)); + std::memcpy(data_field_start + BP0_OFFSET, &bp0, sizeof(bp0)); + std::memcpy(data_field_start + BP1_OFFSET, &bp1, sizeof(bp1)); + std::memcpy(data_field_start + BP2_OFFSET, &bp2, sizeof(bp2)); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + + /* Add crc to packet data field of space packet */ + size_t serializedSize = 0; + uint8_t* crcPos = this->localData.fields.buffer + CRC_OFFSET; + SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } +}; + +/** + * @brief This class generates the space packet to update the time of the PLOC supervisor. + */ +class SetTimeRef: public SpacePacket { +public: + + SetTimeRef(Clock::TimeOfDay_t* time) : + SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_TIME_REF, DEFAULT_SEQUENCE_COUNT) { + initPacket(time); + } + +private: + + static const uint16_t DATA_FIELD_LENGTH = 34; + static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; + static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; + + void initPacket(Clock::TimeOfDay_t* time) { + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&time->second, &data_field_ptr, &serializedSize, + sizeof(time->second), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->minute, &data_field_ptr, &serializedSize, + sizeof(time->minute), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->hour, &data_field_ptr, &serializedSize, + sizeof(time->hour), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->day, &data_field_ptr, &serializedSize, + sizeof(time->day), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->month, &data_field_ptr, &serializedSize, + sizeof(time->month), SerializeIF::Endianness::BIG); + serializedSize = 0; + SerializeAdapter::serialize(&time->year, &data_field_ptr, &serializedSize, + sizeof(time->year), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t milliseconds = time->usecond / 1000; + SerializeAdapter::serialize(&milliseconds, &data_field_ptr, &serializedSize, + sizeof(milliseconds), SerializeIF::Endianness::BIG); + serializedSize = 0; + uint32_t isSet = 0xFFFFFFFF; + SerializeAdapter::serialize(&isSet, &data_field_ptr, &serializedSize, + sizeof(isSet), SerializeIF::Endianness::BIG); + serializedSize = 0; + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } +}; + +/** + * @brief This class can be used to generate the set boot timout command. + */ +class SetBootTimeout: public SpacePacket { +public: + + /** + * @brief Constructor + * + * @param timeout The boot timeout in milliseconds. + */ + SetBootTimeout(uint32_t timeout) : + SpacePacket(DATA_FIELD_LENGTH - 1, true, APID_SET_BOOT_TIMEOUT, 1), timeout(timeout) { + initPacket(); + } + +private: + + uint32_t timeout = 0; + + /** boot timeout value (uint32_t) and crc (uint16_t) */ + static const uint16_t DATA_FIELD_LENGTH = 6; + + void initPacket() { + + size_t serializedSize = 0; + uint8_t* data_field_ptr = this->localData.fields.buffer; + SerializeAdapter::serialize(&timeout, &data_field_ptr, &serializedSize, + sizeof(timeout), SerializeIF::Endianness::BIG); + /* Calculate crc */ + uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, + sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); + /* Add crc to packet data field of space packet */ + serializedSize = 0; + SerializeAdapter::serialize(&crc, &data_field_ptr, &serializedSize, sizeof(crc), + SerializeIF::Endianness::BIG); + } +}; + +/** + * @brief This dataset to store the housekeeping data of the supervisor. + */ +class HkSet: public StaticLocalDataSet { +public: + + HkSet(HasLocalDataPoolIF* owner) : + StaticLocalDataSet(owner, HK_SET_ID) { + } + + HkSet(object_id_t objectId) : + StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) { + } + + lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); + 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 socState = lp_var_t(sid.objectId, PoolIds::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); + lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, 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); +}; +} + +#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCSVPDEFINITIONS_H_ */ diff --git a/mission/devices/devicedefinitions/RadSensorDefinitions.h b/mission/devices/devicedefinitions/RadSensorDefinitions.h index 7d434d04..d3c8e876 100644 --- a/mission/devices/devicedefinitions/RadSensorDefinitions.h +++ b/mission/devices/devicedefinitions/RadSensorDefinitions.h @@ -30,10 +30,11 @@ namespace RAD_SENSOR { * conversions to perform. * @details Bit0: 1 - Enables temperature conversion * Bit2 (SCAN1) and Bit1 (SCAN0): 0b00 (channel conversion from 0 to N) - * Bit6 - Bit3 defines N: 0b0001 (N = 1) + * Bit6 - Bit3 defines N: 0b0111 (N = 7) * Bit7: Always 1. Tells the ADC that this is the conversion register. */ - static const uint8_t CONVERSION_DEFINITION = 0b10001001; + static const uint8_t CONVERSION_DEFINITION = 0b10111001; +// static const uint8_t CONVERSION_DEFINITION = 0b10111111; /** * @brief Writing this value resets the fifo of the MAX1227. @@ -44,18 +45,23 @@ namespace RAD_SENSOR { static const uint8_t RAD_SENSOR_DATA_SET_ID = READ_CONVERSIONS; + static const uint8_t DATASET_ENTRIES = 7; /** - * One temperature value, conversion of channel 0 and conversion of channel 1 + * One temperature value and conversions for AIN0 - AIN7 */ - static const uint8_t READ_SIZE = 6; + static const uint8_t READ_SIZE = 18; enum Max1227PoolIds: lp_id_t { TEMPERATURE_C, - CHANNEL_0, - CHANNEL_1, + AIN0, + AIN1, + AIN4, + AIN5, + AIN6, + AIN7, }; -class RadSensorDataset: public StaticLocalDataSet { +class RadSensorDataset: public StaticLocalDataSet { public: RadSensorDataset(HasLocalDataPoolIF* owner) : @@ -67,8 +73,12 @@ public: } lp_var_t temperatureCelcius = lp_var_t(sid.objectId, TEMPERATURE_C, this); - lp_var_t channel0 = lp_var_t(sid.objectId, CHANNEL_0, this); - lp_var_t channel1 = lp_var_t(sid.objectId, CHANNEL_1, this); + lp_var_t ain0 = lp_var_t(sid.objectId, AIN0, this); + lp_var_t ain1 = lp_var_t(sid.objectId, AIN1, this); + lp_var_t ain4 = lp_var_t(sid.objectId, AIN4, this); + lp_var_t ain5 = lp_var_t(sid.objectId, AIN5, this); + lp_var_t ain6 = lp_var_t(sid.objectId, AIN6, this); + lp_var_t ain7 = lp_var_t(sid.objectId, AIN7, this); }; } diff --git a/mission/devices/devicedefinitions/RwDefinitions.h b/mission/devices/devicedefinitions/RwDefinitions.h index 766c7715..4b3eeee7 100644 --- a/mission/devices/devicedefinitions/RwDefinitions.h +++ b/mission/devices/devicedefinitions/RwDefinitions.h @@ -98,7 +98,7 @@ static const size_t MAX_REPLY_SIZE = 2 * SIZE_GET_TELEMETRY_REPLY; static const uint8_t LAST_RESET_ENTRIES = 2; static const uint8_t TEMPERATURE_SET_ENTRIES = 1; static const uint8_t STATUS_SET_ENTRIES = 4; -static const uint8_t TM_SET_ENTRIES = 22; +static const uint8_t TM_SET_ENTRIES = 24; /** * @brief This dataset can be used to store the temperature of a reaction wheel. diff --git a/mission/devices/devicedefinitions/StarTrackerDefinitions.h b/mission/devices/devicedefinitions/StarTrackerDefinitions.h index cf4353dd..6c28219b 100644 --- a/mission/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/mission/devices/devicedefinitions/StarTrackerDefinitions.h @@ -28,7 +28,7 @@ static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; /** Max size of unencoded frame */ static const size_t MAX_FRAME_SIZE = 1200; -static const uint8_t TEMPERATURE_SET_ENTRIES = 2; +static const uint8_t TEMPERATURE_SET_ENTRIES = 5; /** * @brief This dataset can be used to store the temperature of a reaction wheel. diff --git a/tmtc b/tmtc index 3b073a7e..d55a12a1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 3b073a7eef1313a0781515046483691247e8258d +Subproject commit d55a12a1003540bd1562019e23c4ff0770c6cceb