From 5bd4f56bc6c37bc7620495f9c0e86f130b5a4b18 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 14:17:55 +0100 Subject: [PATCH 01/45] flipped preproc defines --- linux/fsfwconfig/OBSWConfig.h.in | 3 +-- mission/tmtc/CCSDSHandler.h | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index ea26425b..8c25696c 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -39,8 +39,6 @@ debugging. */ // Set to 1 if telecommands are received via the PDEC IP Core #define OBSW_TC_FROM_PDEC 1 -#define TMTC_TEST_SETUP 1 - #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 #define OBSW_ADD_PLOC_SUPERVISOR 0 @@ -78,6 +76,7 @@ debugging. */ //! /* Can be used to switch device to NORMAL mode immediately */ #define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 #define OBSW_PRINT_MISSED_DEADLINES 1 +#define TMTC_TEST_SETUP 0 // If this is enabled, all other SPI code should be disabled #define OBSW_ADD_TEST_CODE 0 #define OBSW_ADD_SPI_TEST_CODE 0 diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 6fb6168b..1ee8575a 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -89,9 +89,9 @@ private: //! [EXPORT] : [COMMENT] Received action message with unknown action id static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); -#if TMTC_TEST_SETUP == 0 - // syrlinks must not be transmitting more than 15 minutes (according to datasheet) - static const uint32_t TRANSMITTER_TIMEOUT = 900000; //900000 ms = 15 min +#if TMTC_TEST_SETUP == 1 + // syrlinks must not be transmitting more than 15 minutes (according to datasheet) + static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 900000 ms = 15 min #else // Set to high value when not sending via syrlinks static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day From eb23dc1b0f80d5209032e4087af496a6d3682d54 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 14:29:03 +0100 Subject: [PATCH 02/45] better names --- linux/fsfwconfig/OBSWConfig.h.in | 3 ++- mission/tmtc/CCSDSHandler.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 8c25696c..fe83c449 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -39,6 +39,7 @@ debugging. */ // Set to 1 if telecommands are received via the PDEC IP Core #define OBSW_TC_FROM_PDEC 1 +#define OBSW_SYRLINKS_DOWNLINK 0 #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 #define OBSW_ADD_PLOC_SUPERVISOR 0 @@ -76,7 +77,7 @@ debugging. */ //! /* Can be used to switch device to NORMAL mode immediately */ #define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 #define OBSW_PRINT_MISSED_DEADLINES 1 -#define TMTC_TEST_SETUP 0 + // If this is enabled, all other SPI code should be disabled #define OBSW_ADD_TEST_CODE 0 #define OBSW_ADD_SPI_TEST_CODE 0 diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 1ee8575a..3840a47f 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -89,13 +89,13 @@ private: //! [EXPORT] : [COMMENT] Received action message with unknown action id static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); -#if TMTC_TEST_SETUP == 1 +#if OBSW_SYRLINKS_DOWNLINK == 1 // syrlinks must not be transmitting more than 15 minutes (according to datasheet) static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 900000 ms = 15 min #else // Set to high value when not sending via syrlinks static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day -#endif /* TMTC_TEST_SETUP == 0 */ +#endif /* OBSW_SYRLINKS_DOWNLINK == 0 */ static const bool UP = true; static const bool DOWN = false; From 32236f98648b21e5e431af0f1d3b81d50e78c0fd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 14:34:20 +0100 Subject: [PATCH 03/45] and another name --- linux/fsfwconfig/OBSWConfig.h.in | 2 +- mission/tmtc/CCSDSHandler.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index fe83c449..f6fc1d6d 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -39,7 +39,7 @@ debugging. */ // Set to 1 if telecommands are received via the PDEC IP Core #define OBSW_TC_FROM_PDEC 1 -#define OBSW_SYRLINKS_DOWNLINK 0 +#define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0 #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 #define OBSW_ADD_PLOC_SUPERVISOR 0 diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 3840a47f..267cef5a 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -89,7 +89,7 @@ private: //! [EXPORT] : [COMMENT] Received action message with unknown action id static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); -#if OBSW_SYRLINKS_DOWNLINK == 1 +#if OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT == 1 // syrlinks must not be transmitting more than 15 minutes (according to datasheet) static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 900000 ms = 15 min #else From 947134bfd1afc6e0c7cd50eecffde7c83e5157b0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 14:39:39 +0100 Subject: [PATCH 04/45] reordered --- linux/fsfwconfig/OBSWConfig.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index f6fc1d6d..06e0b841 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -39,7 +39,6 @@ debugging. */ // Set to 1 if telecommands are received via the PDEC IP Core #define OBSW_TC_FROM_PDEC 1 -#define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0 #define OBSW_ENABLE_TIMERS 1 #define OBSW_ADD_STAR_TRACKER 0 #define OBSW_ADD_PLOC_SUPERVISOR 0 @@ -51,6 +50,7 @@ debugging. */ #define OBSW_ADD_TMP_DEVICES 0 #define OBSW_ADD_RAD_SENSORS 0 #define OBSW_ADD_SYRLINKS 0 +#define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0 #elif defined RASPBERRY_PI From f948905aa2b60d793547ba3aa627a503cebbae63 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 17:10:51 +0100 Subject: [PATCH 05/45] implemented first switch callback --- bsp_q7s/core/InitMission.cpp | 2 +- fsfw | 2 +- mission/devices/ACUHandler.cpp | 3 +- mission/devices/ACUHandler.h | 3 +- mission/devices/GPSHyperionHandler.cpp | 4 +- mission/devices/GomspaceDeviceHandler.cpp | 22 +++++++--- mission/devices/GomspaceDeviceHandler.h | 11 ++++- mission/devices/PDU1Handler.cpp | 50 +++++++++++++++++++++++ mission/devices/PDU1Handler.h | 7 ++++ 9 files changed, 89 insertions(+), 15 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index a5b2b548..96a43a81 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -206,7 +206,7 @@ void initmission::initTasks() { #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - //acsCtrl->startTask(); + // acsCtrl->startTask(); sif::info << "Tasks started.." << std::endl; } diff --git a/fsfw b/fsfw index 933da2f6..9b770602 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 933da2f655717b66c1056e764c47a2eee473a137 +Subproject commit 9b77060295c9c32ebfc2e7cf6517eb2e66216191 diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 239a0c7a..60e26302 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -273,7 +273,8 @@ ReturnValue_t ACUHandler::initializeLocalDataPool(localpool::DataPool &localData return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t ACUHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { +ReturnValue_t ACUHandler::childCommandHook(DeviceCommandId_t cmd, const uint8_t *commandData, + size_t commandDataLen) { switch (cmd) { case PRINT_CHANNEL_STATS: { printChannelStats(); diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index 0d93c5fe..f3af5eae 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -28,7 +28,8 @@ class ACUHandler : public GomspaceDeviceHandler { virtual void fillCommandAndReplyMap() override; - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd) override; + virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t* commandData, + size_t commandDataLen) override; private: static const DeviceCommandId_t PRINT_CHANNEL_STATS = 51; diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 37b11bcb..9bea91b0 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -30,9 +30,7 @@ void GPSHyperionHandler::performControlOperation() { #endif } -LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return &gpsSet; -} +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return &gpsSet; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index eea1368a..c2abd330 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -36,7 +36,7 @@ ReturnValue_t GomspaceDeviceHandler::buildTransitionDeviceCommand(DeviceCommandI ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result; + ReturnValue_t result = childCommandHook(deviceCommand, commandData, commandDataLen); switch (deviceCommand) { case (GOMSPACE::PING): { result = generatePingCommand(commandData, commandDataLen); @@ -82,7 +82,7 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d break; } default: - return deviceSpecificCommand(deviceCommand); + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } return HasReturnvaluesIF::RETURN_OK; } @@ -195,6 +195,10 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm << std::endl; return result; } + result = setParamCallback(setParamMessageUnpacker); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } /* Get and check address */ uint16_t address = setParamMessageUnpacker.getAddress(); if (address > maxConfigTableAddress) { @@ -335,6 +339,16 @@ void GomspaceDeviceHandler::generateRebootCommand() { rawPacketLen = cspPacketLen; } +ReturnValue_t GomspaceDeviceHandler::childCommandHook(DeviceCommandId_t cmd, + const uint8_t* commandData, + size_t commandDataLen) { + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; +} + +ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& unpacker) { + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t GomspaceDeviceHandler::generateResetWatchdogCmd() { WatchdogResetCommand watchdogResetCommand; size_t cspPacketLen = 0; @@ -386,10 +400,6 @@ LocalPoolDataSetBase* GomspaceDeviceHandler::getDataSetHandle(sid_t sid) { } } -ReturnValue_t GomspaceDeviceHandler::deviceSpecificCommand(DeviceCommandId_t cmd) { - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; -} - void GomspaceDeviceHandler::setModeNormal() { mode = MODE_NORMAL; } ReturnValue_t GomspaceDeviceHandler::printStatus(DeviceCommandId_t cmd) { diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index c9c08609..22b97ef7 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -1,6 +1,8 @@ #ifndef MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ #define MISSION_DEVICES_GOMSPACEDEVICEHANDLER_H_ +#include + #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "mission/devices/devicedefinitions/GomspaceDefinitions.h" #include "returnvalues/classIds.h" @@ -101,9 +103,12 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { virtual LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; /** - * @brief Can be used by gomspace devices to implement device specific commands. + * @brief Can be overriden by child classes to implement device specific commands. + * @return Return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED to let this handler handle + * the command or RETURN_OK if the child handles the command */ - virtual ReturnValue_t deviceSpecificCommand(DeviceCommandId_t cmd); + virtual ReturnValue_t childCommandHook(DeviceCommandId_t cmd, const uint8_t *commandData, + size_t commandDataLen); private: /** @@ -112,6 +117,8 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { */ ReturnValue_t generateSetParamCommand(const uint8_t *commandData, size_t commandDataLen); + virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker); + /** * @brief Function to generate the command to get a parameter from a * gomspace device. Command will be sent to the ComIF over the diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index a1486588..e7e91fbf 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -1,6 +1,7 @@ #include "PDU1Handler.h" #include +#include #include "OBSWConfig.h" @@ -67,6 +68,55 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } +void PDU1Handler::assignChannelHookFunction(ChannelSwitchHook hook) { + this->channelSwitchHook = hook; +} + +ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { + using namespace PDU1; + if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { + switch (unpacker.getAddress()) { + case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3): { + channelSwitchHook(0, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SYRLINKS): { + channelSwitchHook(1, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_STAR_TRACKER): { + channelSwitchHook(2, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_MGT): { + channelSwitchHook(3, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL): { + channelSwitchHook(4, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP): { + channelSwitchHook(5, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PLOC): { + channelSwitchHook(6, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A): { + channelSwitchHook(7, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_CHANNEL8): { + channelSwitchHook(8, unpacker.getParameter()[0]); + break; + } + } + } + return HasReturnvaluesIF::RETURN_OK; +} + void PDU1Handler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; PoolReadGuard pg(&pdu1HkTableDataset); diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 0715b078..911e65be 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -4,6 +4,8 @@ #include "GomspaceDeviceHandler.h" #include "devicedefinitions/GomspaceDefinitions.h" +using ChannelSwitchHook = void (*)(uint8_t channel, bool on); + /** * @brief This is the device handler for the PDU1. * @@ -27,6 +29,8 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; + void assignChannelHookFunction(ChannelSwitchHook hook); + protected: /** * @brief In MODE_NORMAL, a command will be built periodically by this function. @@ -35,9 +39,12 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; + ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker) override; + private: /** Dataset for the housekeeping table of the PDU1 */ PDU1::PDU1HkTableDataset pdu1HkTableDataset; + ChannelSwitchHook channelSwitchHook = nullptr; void printHkTable(); void parseHkTableReply(const uint8_t* packet); From 79fac2adcb2588b8000b448bef4e34c662ecbd1d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 17:17:06 +0100 Subject: [PATCH 06/45] callbacks are now allowed --- mission/devices/PDU1Handler.cpp | 2 +- mission/devices/PDU1Handler.h | 6 +-- mission/devices/PDU2Handler.cpp | 49 +++++++++++++++++++ mission/devices/PDU2Handler.h | 5 +- .../devicedefinitions/GomspaceDefinitions.h | 3 ++ 5 files changed, 58 insertions(+), 7 deletions(-) diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index e7e91fbf..f4bd2839 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -68,7 +68,7 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } -void PDU1Handler::assignChannelHookFunction(ChannelSwitchHook hook) { +void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { this->channelSwitchHook = hook; } diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 911e65be..fea8395e 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -4,8 +4,6 @@ #include "GomspaceDeviceHandler.h" #include "devicedefinitions/GomspaceDefinitions.h" -using ChannelSwitchHook = void (*)(uint8_t channel, bool on); - /** * @brief This is the device handler for the PDU1. * @@ -29,7 +27,7 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - void assignChannelHookFunction(ChannelSwitchHook hook); + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); protected: /** @@ -44,7 +42,7 @@ class PDU1Handler : public GomspaceDeviceHandler { private: /** Dataset for the housekeeping table of the PDU1 */ PDU1::PDU1HkTableDataset pdu1HkTableDataset; - ChannelSwitchHook channelSwitchHook = nullptr; + GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; void printHkTable(); void parseHkTableReply(const uint8_t* packet); diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index b5c34af6..68d903f3 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -49,6 +49,10 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } +void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { + this->channelSwitchHook = hook; +} + void PDU2Handler::parseHkTableReply(const uint8_t *packet) { uint16_t dataOffset = 0; pdu2HkTableDataset.read(); @@ -421,3 +425,48 @@ void PDU2Handler::printHkTable() { << std::setw(4) << pdu2HkTableDataset.voltageOutPayloadCamera.value << std::right << std::endl; } + +ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { + using namespace PDU2; + if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { + switch (unpacker.getAddress()) { + case (CONFIG_ADDRESS_OUT_EN_Q7S): { + channelSwitchHook(0, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1): { + channelSwitchHook(1, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_RW): { + channelSwitchHook(2, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN): { + channelSwitchHook(3, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT): { + channelSwitchHook(4, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM): { + channelSwitchHook(5, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC): { + channelSwitchHook(6, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B): { + channelSwitchHook(7, unpacker.getParameter()[0]); + break; + } + case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA): { + channelSwitchHook(8, unpacker.getParameter()[0]); + break; + } + } + } + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index 258b616d..20cfd52c 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -26,7 +26,7 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); protected: /** * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. @@ -34,10 +34,11 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - + ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker) override; private: /** Dataset for the housekeeping table of the PDU2 */ PDU2::PDU2HkTableDataset pdu2HkTableDataset; + GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; void printHkTable(); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index a575747f..64fdd426 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -16,6 +16,9 @@ #include namespace GOMSPACE { + +using ChannelSwitchHook = void (*)(uint8_t channel, bool on); + static const uint16_t IGNORE_CHECKSUM = 0xbb0; /** The size of the header of a gomspace CSP packet. */ static const uint8_t GS_HDR_LENGTH = 12; From 1eb6017a9d2a3660636e1bcca305c27e13698991 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:05:17 +0100 Subject: [PATCH 07/45] callback working --- bsp_q7s/callbacks/CMakeLists.txt | 1 + bsp_q7s/callbacks/pcduSwitchCb.cpp | 32 ++++++++++++ bsp_q7s/callbacks/pcduSwitchCb.h | 14 +++++ bsp_q7s/core/ObjectFactory.cpp | 12 +++-- bsp_q7s/core/ObjectFactory.h | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 3 +- .../pollingSequenceFactory.cpp | 4 +- mission/devices/PDU1Handler.cpp | 22 ++++---- mission/devices/PDU1Handler.h | 3 +- mission/devices/PDU2Handler.cpp | 24 +++++---- mission/devices/PDU2Handler.h | 7 ++- .../devicedefinitions/GomspaceDefinitions.h | 52 +++++++++++++------ 12 files changed, 129 insertions(+), 47 deletions(-) create mode 100644 bsp_q7s/callbacks/pcduSwitchCb.cpp create mode 100644 bsp_q7s/callbacks/pcduSwitchCb.h diff --git a/bsp_q7s/callbacks/CMakeLists.txt b/bsp_q7s/callbacks/CMakeLists.txt index 8c83e26f..a85bf6fb 100644 --- a/bsp_q7s/callbacks/CMakeLists.txt +++ b/bsp_q7s/callbacks/CMakeLists.txt @@ -1,4 +1,5 @@ target_sources(${TARGET_NAME} PRIVATE rwSpiCallback.cpp gnssCallback.cpp + pcduSwitchCb.cpp ) diff --git a/bsp_q7s/callbacks/pcduSwitchCb.cpp b/bsp_q7s/callbacks/pcduSwitchCb.cpp new file mode 100644 index 00000000..ec5f4dc5 --- /dev/null +++ b/bsp_q7s/callbacks/pcduSwitchCb.cpp @@ -0,0 +1,32 @@ +#include "pcduSwitchCb.h" + +#include + +#include "devices/gpioIds.h" + +void pcdu::switchCallback(GOMSPACE::Pdu pdu, uint8_t channel, bool state, void* args) { + LinuxLibgpioIF* gpioComIF = reinterpret_cast(args); + if (gpioComIF == nullptr) { + return; + } + if (pdu == GOMSPACE::Pdu::PDU1) { + PDU1::SwitchChannels typedChannel = static_cast(channel); + if (typedChannel == PDU1::SwitchChannels::ACS_A_SIDE) { + if (state) { + gpioComIF->pullHigh(gpioIds::GNSS_0_NRESET); + } else { + gpioComIF->pullLow(gpioIds::GNSS_0_NRESET); + } + } + + } else if (pdu == GOMSPACE::Pdu::PDU2) { + PDU2::SwitchChannels typedChannel = static_cast(channel); + if (typedChannel == PDU2::SwitchChannels::ACS_B_SIDE) { + if (state) { + gpioComIF->pullHigh(gpioIds::GNSS_1_NRESET); + } else { + gpioComIF->pullLow(gpioIds::GNSS_1_NRESET); + } + } + } +} diff --git a/bsp_q7s/callbacks/pcduSwitchCb.h b/bsp_q7s/callbacks/pcduSwitchCb.h new file mode 100644 index 00000000..d0f2b748 --- /dev/null +++ b/bsp_q7s/callbacks/pcduSwitchCb.h @@ -0,0 +1,14 @@ +#ifndef BSP_Q7S_CALLBACKS_PCDUSWITCHCB_H_ +#define BSP_Q7S_CALLBACKS_PCDUSWITCHCB_H_ + +#include + +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" + +namespace pcdu { + +void switchCallback(GOMSPACE::Pdu pdu, uint8_t channel, bool state, void* args); + +} + +#endif /* BSP_Q7S_CALLBACKS_PCDUSWITCHCB_H_ */ diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 69f6dfaf..5867c977 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -3,6 +3,7 @@ #include #include "OBSWConfig.h" +#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" @@ -122,13 +123,14 @@ void ObjectFactory::produce(void* args) { #if BOARD_TE0720 == 0 new CoreController(objects::CORE_CONTROLLER); - createPcduComponents(); + createPcduComponents(gpioComIF); createRadSensorComponent(gpioComIF); createSunSensorComponents(gpioComIF, spiComIF); #if OBSW_ADD_ACS_BOARD == 1 createAcsBoardComponents(gpioComIF, uartComIF); -#endif /* OBSW_ADD_ACS_BOARD == 1 */ +#endif + createHeaterComponents(); createSolarArrayDeploymentComponents(); #if OBSW_ADD_SYRLINKS == 1 @@ -234,7 +236,7 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, Ua #endif } -void ObjectFactory::createPcduComponents() { +void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF) { CspCookie* p60DockCspCookie = new CspCookie(P60Dock::MAX_REPLY_LENGTH, addresses::P60DOCK); CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1); CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2); @@ -244,8 +246,10 @@ void ObjectFactory::createPcduComponents() { new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); PDU1Handler* pdu1handler = new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); + pdu1handler->assignChannelHookFunction(&pcdu::switchCallback, gpioComIF); PDU2Handler* pdu2handler = new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); + pdu2handler->assignChannelHookFunction(&pcdu::switchCallback, gpioComIF); ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); new PCDUHandler(objects::PCDU_HANDLER, 50); @@ -472,6 +476,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI gpioComIF->addGpios(gpioCookieAcsBoard); +#if OBSW_ADD_ACS_HANDLERS == 1 std::string spiDev = q7s::SPI_DEFAULT_DEV; SpiCookie* spiCookie = new SpiCookie(addresses::MGM_0_LIS3, gpioIds::MGM_0_LIS3_CS, spiDev, @@ -561,6 +566,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComI resetArgsGnss0.waitPeriodMs = 100; auto gpsHandler0 = new GPSHyperionHandler(objects::GPS_CONTROLLER, objects::NO_OBJECT, debugGps); gpsHandler0->setResetPinTriggerFunction(gps::triggerGpioResetPin, &resetArgsGnss0); +#endif /* OBSW_ADD_ACS_HANDLERS == 1 */ } void ObjectFactory::createHeaterComponents() { diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 47e06e33..8fa4a147 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -13,7 +13,7 @@ void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, SpiComIF** spiComIF); void createTmpComponents(); -void createPcduComponents(); +void createPcduComponents(LinuxLibgpioIF* gpioComIF); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); void createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF); void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF); diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index ea26425b..5d501eb6 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -46,7 +46,8 @@ debugging. */ #define OBSW_ADD_PLOC_SUPERVISOR 0 #define OBSW_ADD_PLOC_MPSOC 0 #define OBSW_ADD_SUN_SENSORS 0 -#define OBSW_ADD_ACS_BOARD 0 +#define OBSW_ADD_ACS_BOARD 1 +#define OBSW_ADD_ACS_HANDLERS 0 #define OBSW_ADD_RW 0 #define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_TMP_DEVICES 0 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 814e5c2d..0675cf0d 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -435,7 +435,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #endif -#if OBSW_ADD_ACS_BOARD == 1 +#if OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1 bool enableAside = true; bool enableBside = false; if (enableAside) { @@ -501,7 +501,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.75, DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.85, DeviceHandlerIF::GET_READ); } -#endif /* OBSW_ADD_ACS_BOARD == 1 */ +#endif /* OBSW_ADD_ACS_BOARD == 1 && OBSW_ADD_ACS_HANDLERS == 1 */ ReturnValue_t seqCheck = thisSequence->checkSequence(); if (seqCheck != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index f4bd2839..6f2fd01e 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -68,48 +68,50 @@ void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } -void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { +void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { this->channelSwitchHook = hook; + this->hookArgs = args; } ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { using namespace PDU1; + GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { switch (unpacker.getAddress()) { case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3): { - channelSwitchHook(0, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 0, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SYRLINKS): { - channelSwitchHook(1, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_STAR_TRACKER): { - channelSwitchHook(2, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_MGT): { - channelSwitchHook(3, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL): { - channelSwitchHook(4, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP): { - channelSwitchHook(5, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PLOC): { - channelSwitchHook(6, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A): { - channelSwitchHook(7, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_CHANNEL8): { - channelSwitchHook(8, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs); break; } } diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index fea8395e..9b60e7e9 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -27,7 +27,7 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void* args); protected: /** @@ -43,6 +43,7 @@ class PDU1Handler : public GomspaceDeviceHandler { /** Dataset for the housekeeping table of the PDU1 */ PDU1::PDU1HkTableDataset pdu1HkTableDataset; GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; + void* hookArgs = nullptr; void printHkTable(); void parseHkTableReply(const uint8_t* packet); diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 68d903f3..d2d879f8 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -49,8 +49,9 @@ void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *pac #endif } -void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook) { - this->channelSwitchHook = hook; +void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { + this->channelSwitchHook = hook; + this->hookArgs = args; } void PDU2Handler::parseHkTableReply(const uint8_t *packet) { @@ -428,42 +429,43 @@ void PDU2Handler::printHkTable() { ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { using namespace PDU2; + GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { switch (unpacker.getAddress()) { case (CONFIG_ADDRESS_OUT_EN_Q7S): { - channelSwitchHook(0, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 0, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH1): { - channelSwitchHook(1, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 1, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_RW): { - channelSwitchHook(2, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 2, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_HEATER_IN): { - channelSwitchHook(3, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 3, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_SUS_REDUNDANT): { - channelSwitchHook(4, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 4, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_DEPLOYMENT_MECHANISM): { - channelSwitchHook(5, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 5, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_PCDU_CH6PLOC): { - channelSwitchHook(6, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 6, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_B): { - channelSwitchHook(7, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 7, unpacker.getParameter()[0], hookArgs); break; } case (CONFIG_ADDRESS_OUT_EN_PAYLOAD_CAMERA): { - channelSwitchHook(8, unpacker.getParameter()[0]); + channelSwitchHook(pdu, 8, unpacker.getParameter()[0], hookArgs); break; } } diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index 20cfd52c..b721ce58 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -26,7 +26,8 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook); + void assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void* args); + protected: /** * @brief As soon as the device is in MODE_NORMAL, this function is executed periodically. @@ -34,11 +35,13 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker) override; + ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker) override; + private: /** Dataset for the housekeeping table of the PDU2 */ PDU2::PDU2HkTableDataset pdu2HkTableDataset; GOMSPACE::ChannelSwitchHook channelSwitchHook = nullptr; + void* hookArgs = nullptr; void printHkTable(); diff --git a/mission/devices/devicedefinitions/GomspaceDefinitions.h b/mission/devices/devicedefinitions/GomspaceDefinitions.h index 64fdd426..fde4e047 100644 --- a/mission/devices/devicedefinitions/GomspaceDefinitions.h +++ b/mission/devices/devicedefinitions/GomspaceDefinitions.h @@ -1,11 +1,3 @@ -/* - * GomspaceDefinitions.h - * - * @brief This file holds all definitions specific for devices from gomspace. - * @date 20.12.2020 - * @author J. Meier - */ - #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEDEFINITIONS_H_ @@ -17,7 +9,9 @@ namespace GOMSPACE { -using ChannelSwitchHook = void (*)(uint8_t channel, bool on); +enum class Pdu { PDU1, PDU2 }; + +using ChannelSwitchHook = void (*)(Pdu pdu, uint8_t channel, bool on, void* args); static const uint16_t IGNORE_CHECKSUM = 0xbb0; /** The size of the header of a gomspace CSP packet. */ @@ -614,19 +608,32 @@ static const uint8_t HK_TABLE_ENTRIES = 73; namespace PDU1 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x1; // hk table has table id 4 + +enum SwitchChannels : uint8_t { + TCS_BOARD_3V3 = 0, + SYRLINKS = 1, + STR = 2, + MGT = 3, + SUS_NOMINAL = 4, + SOL_CELL_EXPERIMENT = 5, + PLOC = 6, + ACS_A_SIDE = 7, + UNUSED = 8 +}; + /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. */ static const uint16_t CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3 = 0x48; static const uint16_t CONFIG_ADDRESS_OUT_EN_SYRLINKS = 0x49; -static const uint16_t CONFIG_ADDRESS_OUT_EN_STAR_TRACKER = 0x50; -static const uint16_t CONFIG_ADDRESS_OUT_EN_MGT = 0x51; -static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL = 0x52; -static const uint16_t CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP = 0x53; -static const uint16_t CONFIG_ADDRESS_OUT_EN_PLOC = 0x54; -static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A = 0x55; -static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x56; +static const uint16_t CONFIG_ADDRESS_OUT_EN_STAR_TRACKER = 0x4A; +static const uint16_t CONFIG_ADDRESS_OUT_EN_MGT = 0x4B; +static const uint16_t CONFIG_ADDRESS_OUT_EN_SUS_NOMINAL = 0x4C; +static const uint16_t CONFIG_ADDRESS_OUT_EN_SOLAR_CELL_EXP = 0x4D; +static const uint16_t CONFIG_ADDRESS_OUT_EN_PLOC = 0x4E; +static const uint16_t CONFIG_ADDRESS_OUT_EN_ACS_BOARD_SIDE_A = 0x4F; +static const uint16_t CONFIG_ADDRESS_OUT_EN_CHANNEL8 = 0x50; /** * @brief This class defines a dataset for the hk table of the PDU1. @@ -802,6 +809,19 @@ class PDU1HkTableDataset : public StaticLocalDataSet { namespace PDU2 { static const uint32_t HK_TABLE_DATA_SET_ID = 0x2; + +enum SwitchChannels : uint8_t { + Q7S = 0, + PAYLOAD_PCDU_CH1 = 1, + RW = 2, + TCS_HEATER_IN = 3, + SUS_REDUNDANT = 4, + DEPY_MECHANISM = 5, + PAYLOAD_PCDU_CH6 = 6, + ACS_B_SIDE = 7, + PAYLOAD_CAMERA = 8 +}; + /** * Addresses within configuration table to enable or disable output channels. Refer also to * gs-man-nanopower-p60-pdu-200.pdf on page 16. From 68eb7c9271de87b3b978a50c63f3566f68d08d90 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:11:35 +0100 Subject: [PATCH 08/45] removed clang script in root --- apply-clang-format.sh | 11 ----------- bsp_q7s/core/ObjectFactory.cpp | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100755 apply-clang-format.sh diff --git a/apply-clang-format.sh b/apply-clang-format.sh deleted file mode 100755 index 6d77c6e9..00000000 --- a/apply-clang-format.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -if [[ ! -f README.md ]]; then - cd .. -fi - -find ./mission -iname *.h o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./linux -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./bsp_q7s -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./bsp_linux_board -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./bsp_hosted -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i -find ./test -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 5867c977..7c089465 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -3,9 +3,9 @@ #include #include "OBSWConfig.h" -#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" +#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/devices/PlocMemoryDumper.h" From 4913ffa6d46640991e2c68525fecb6c9f2b46003 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:21:17 +0100 Subject: [PATCH 09/45] removed unrelated changes --- mission/devices/GPSHyperionHandler.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 9bea91b0..d49b9db4 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -30,7 +30,7 @@ void GPSHyperionHandler::performControlOperation() { #endif } -LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return &gpsSet; } +LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { return nullptr; } ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { @@ -59,7 +59,6 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); - localDataPoolMap.emplace(GpsHyperion::SPEED, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); @@ -68,7 +67,6 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); return HasReturnvaluesIF::RETURN_OK; From ded92fdf7ab4a7d1590bbef9460e5e56ce5ed90f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 19 Jan 2022 18:51:44 +0100 Subject: [PATCH 10/45] call param callback twice --- mission/devices/GomspaceDeviceHandler.cpp | 15 ++++++++------- mission/devices/GomspaceDeviceHandler.h | 11 ++++++++++- mission/devices/PDU1Handler.cpp | 5 ++++- mission/devices/PDU1Handler.h | 2 +- mission/devices/PDU2Handler.cpp | 5 ++++- mission/devices/PDU2Handler.h | 2 +- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index c2abd330..ce86d13a 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -170,6 +170,7 @@ ReturnValue_t GomspaceDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, if (*packet != PARAM_SET_OK) { return HasReturnvaluesIF::RETURN_FAILED; } + setParamCallback(setParamCacher, true); break; } case (GOMSPACE::REQUEST_HK_TABLE): { @@ -186,8 +187,7 @@ void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {} ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData, size_t commandDataLen) { - SetParamMessageUnpacker setParamMessageUnpacker; - ReturnValue_t result = setParamMessageUnpacker.deSerialize(&commandData, &commandDataLen, + ReturnValue_t result = setParamCacher.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " @@ -195,12 +195,12 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm << std::endl; return result; } - result = setParamCallback(setParamMessageUnpacker); + result = setParamCallback(setParamCacher, false); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } /* Get and check address */ - uint16_t address = setParamMessageUnpacker.getAddress(); + uint16_t address = setParamCacher.getAddress(); if (address > maxConfigTableAddress) { sif::error << "GomspaceDeviceHandler: Invalid address for set parameter " << "action" << std::endl; @@ -211,8 +211,8 @@ ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* comm uint16_t total = 0; /* CSP reply only contains the transaction state */ uint16_t querySize = 1; - const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter(); - uint8_t parameterSize = setParamMessageUnpacker.getParameterSize(); + const uint8_t* parameterPtr = setParamCacher.getParameter(); + uint8_t parameterSize = setParamCacher.getParameterSize(); uint16_t payloadlength = sizeof(address) + parameterSize; /* Generate command for CspComIF */ @@ -345,7 +345,8 @@ ReturnValue_t GomspaceDeviceHandler::childCommandHook(DeviceCommandId_t cmd, return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; } -ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& unpacker) { +ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& unpacker, + bool afterExecution) { return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 22b97ef7..efe18ee5 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -111,13 +111,22 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { size_t commandDataLen); private: + SetParamMessageUnpacker setParamCacher; /** * @brief Function to generate the command to set a parameter. Command * will be sent to the ComIF over the rawPacket buffer. */ ReturnValue_t generateSetParamCommand(const uint8_t *commandData, size_t commandDataLen); - virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker); + /** + * Callback is called on a parameter set command. It is called before executing it and after + * after successful execution + * @param unpacker Passed before + * @param beforeSet False for callback before execution, true if called after successful + * execution + * @return + */ + virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExecution); /** * @brief Function to generate the command to get a parameter from a diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index 6f2fd01e..d1276c7f 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -73,9 +73,12 @@ void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, vo this->hookArgs = args; } -ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { +ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { using namespace PDU1; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; + if(not afterExecution) { + return HasReturnvaluesIF::RETURN_OK; + } if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { switch (unpacker.getAddress()) { case (CONFIG_ADDRESS_OUT_EN_TCS_BOARD_3V3): { diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 9b60e7e9..c140648b 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -37,7 +37,7 @@ class PDU1Handler : public GomspaceDeviceHandler { virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker) override; + ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExectuion) override; private: /** Dataset for the housekeeping table of the PDU1 */ diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index d2d879f8..61e9bb6a 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -427,9 +427,12 @@ void PDU2Handler::printHkTable() { << std::endl; } -ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker) { +ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; + if(not afterExecution) { + return HasReturnvaluesIF::RETURN_OK; + } if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { switch (unpacker.getAddress()) { case (CONFIG_ADDRESS_OUT_EN_Q7S): { diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index b721ce58..f2323615 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -35,7 +35,7 @@ class PDU2Handler : public GomspaceDeviceHandler { virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; virtual void letChildHandleHkReply(DeviceCommandId_t id, const uint8_t* packet) override; ReturnValue_t printStatus(DeviceCommandId_t cmd) override; - ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker) override; + ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExecution) override; private: /** Dataset for the housekeeping table of the PDU2 */ From a56224c339467bce1f17b5a9e92c59cba0787e17 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 24 Jan 2022 07:43:14 +0100 Subject: [PATCH 11/45] ptme axi interface --- bsp_q7s/boardconfig/busConf.h | 2 +- bsp_q7s/core/ObjectFactory.cpp | 15 +++-------- common/config/commonObjects.h | 4 ++- fsfw | 2 +- linux/obc/CMakeLists.txt | 1 + linux/obc/PtmeAxiConfig.cpp | 49 ++++++++++++++++++++++++++++++++++ linux/obc/PtmeAxiConfig.h | 40 +++++++++++++++++++++++++++ linux/obc/PtmeConfig.h | 3 ++- linux/obc/PtmeRateSetter.cpp | 38 ++++++++++++++++++-------- linux/obc/PtmeRateSetter.h | 42 ++++++++++++++--------------- linux/obc/TxRateSetterIF.h | 9 ++++++- mission/tmtc/CCSDSHandler.cpp | 4 +-- mission/tmtc/CCSDSHandler.h | 3 +++ tmtc | 2 +- 14 files changed, 163 insertions(+), 51 deletions(-) create mode 100644 linux/obc/PtmeAxiConfig.cpp create mode 100644 linux/obc/PtmeAxiConfig.h diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index e41ed093..5abd109b 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -17,6 +17,7 @@ static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; +static constexpr char UIO_PTME_CONFIG[] = "/dev/uio4"; namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; @@ -69,7 +70,6 @@ static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; static constexpr char RS485_EN_RX_CLOCK[] = "rx_clock_enable_ltc2872"; static constexpr char RS485_EN_RX_DATA[] = "rx_data_enable_ltc2872"; static constexpr char PDEC_RESET[] = "pdec_reset"; -static constexpr char BIT_RATE_SEL[] = "bit_rate_sel"; } // namespace gpioNames } // namespace q7s diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7c089465..6db63f30 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -81,6 +81,7 @@ #include #include #include +#include ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; @@ -943,17 +944,9 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { ptme->addVcInterface(ccsds::VC2, vc2); ptme->addVcInterface(ccsds::VC3, vc3); - GpioCookie* gpioCookieRateSetter = new GpioCookie; - consumer.str(""); - consumer << "ptme rate setter"; - // Init to low -> default bit rate is low bit rate (200 kbps in downlink with syrlinks) - gpio = new GpiodRegularByLineName(q7s::gpioNames::BIT_RATE_SEL, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRateSetter->addGpio(gpioIds::BIT_RATE_SEL, gpio); - gpioComIF->addGpios(gpioCookieRateSetter); - - TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); - + PtmeAxiConfig* ptmeAxiConfig = new PtmeAxiConfig(objects::PTME_AXI_CONFIG, + std::string(q7s::UIO_PTME_CONFIG)); + TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(objects::TX_RATE_SETTER, ptmeAxiConfig); CCSDSHandler* ccsdsHandler = new CCSDSHandler( objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF, gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA); diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 135259d6..e29a2013 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -90,7 +90,9 @@ enum commonObjects: uint32_t { PLOC_UPDATER = 0x44330000, PLOC_MEMORY_DUMPER = 0x44330001, - STR_HELPER = 0x44330002 + STR_HELPER = 0x44330002, + PTME_AXI_CONFIG = 44330003, + TX_RATE_SETTER = 44330004 }; } diff --git a/fsfw b/fsfw index 9b770602..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9b77060295c9c32ebfc2e7cf6517eb2e66216191 +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 diff --git a/linux/obc/CMakeLists.txt b/linux/obc/CMakeLists.txt index 4119624c..d59a1a5f 100644 --- a/linux/obc/CMakeLists.txt +++ b/linux/obc/CMakeLists.txt @@ -4,6 +4,7 @@ target_sources(${TARGET_NAME} PUBLIC PdecHandler.cpp PdecConfig.cpp PtmeRateSetter.cpp + PtmeAxiConfig.cpp ) diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp new file mode 100644 index 00000000..3ec45faa --- /dev/null +++ b/linux/obc/PtmeAxiConfig.cpp @@ -0,0 +1,49 @@ +#include +#include +#include "PtmeAxiConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio) : + SystemObject(objectId), configAxiUio(configAxiUio) { + mutex = MutexFactory::instance()->createMutex(); + if (mutex == nullptr) { + sif::warning << "Failed to create mutex" << std::endl; + } +} + +PtmeAxiConfig::~PtmeAxiConfig() { +} + +ReturnValue_t PtmeAxiConfig::initialize() { + int fd = open(configAxiUio.c_str(), O_RDWR); + if (fd < 1) { + sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + baseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, + fd, 0)); + + if (baseAddress == MAP_FAILED) { + sif::warning << "PtmeAxiConfig::initialize: Failed to map uio address" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t PtmeAxiConfig::writeCaduRateReg(uint8_t rateVal) { + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + result = mutex->lockMutex(timeoutType, mutexTimeout); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to lock mutex" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + *(baseAddress + CADU_BITRATE_REG) = static_cast(rateVal); + result = mutex->unlockMutex(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to unlock mutex" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + diff --git a/linux/obc/PtmeAxiConfig.h b/linux/obc/PtmeAxiConfig.h new file mode 100644 index 00000000..2b3e9d26 --- /dev/null +++ b/linux/obc/PtmeAxiConfig.h @@ -0,0 +1,40 @@ +#ifndef LINUX_OBC_PTMEAXICONFIG_H_ +#define LINUX_OBC_PTMEAXICONFIG_H_ + +#include +#include "fsfw/ipc/MutexIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/objectmanager/SystemObject.h" + +/** + * @brief Class providing low level access to the configuration interface of the PTME. + * + * @author J. Meier + */ +class PtmeAxiConfig : public SystemObject { +public: + /** + * @brief Constructor + * @param configAxiUio Device file of UIO belonging to the AXI configuration interface. + */ + PtmeAxiConfig(object_id_t objectId, std::string configAxiUio); + virtual ~PtmeAxiConfig(); + + virtual ReturnValue_t initialize() override; + ReturnValue_t writeCaduRateReg(uint8_t rateVal); + +private: + // Address of register storing the bitrate configuration parameter + static const uint32_t CADU_BITRATE_REG = 0x0; + static const int MAP_SIZE = 0x1000; + + std::string configAxiUio; + MutexIF* mutex = nullptr; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t mutexTimeout = 20; + + uint32_t* baseAddress = nullptr; + +}; + +#endif /* LINUX_OBC_PTMEAXICONFIG_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index b5b722ac..2dd7b7b2 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -25,7 +25,8 @@ static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif - +// Bit clock frequency of PMTE IP core in Hz +static const uint32_t BIT_CLK_FREQ = 20000000; }; // namespace PtmeConfig #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index b5a6ee1c..4a81c361 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -2,24 +2,40 @@ #include "fsfw/serviceinterface/ServiceInterface.h" -PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) - : bitrateSel(bitrateSel), gpioif(gpioif) {} +PtmeRateSetter::PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig) + : SystemObject(objectId), ptmeAxiConfig(ptmeAxiConfig) {} PtmeRateSetter::~PtmeRateSetter() {} +ReturnValue_t PtmeRateSetter::initialize() { + if (ptmeAxiConfig == nullptr) { + sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + uint8_t rateVal = 0; switch (rate) { - case RATE_2000KHZ: - result = gpioif->pullHigh(bitrateSel); + case RATE_2000KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 2000000 - 1); break; - case RATE_400KHZ: - result = gpioif->pullLow(bitrateSel); + case RATE_1000KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 1000000 - 1); + break; + case RATE_500KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 500000 - 1); + break; + case RATE_200KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 200000 - 1); + break; + case RATE_100KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 100000 - 1); break; default: - sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; - result = HasReturnvaluesIF::RETURN_FAILED; - break; + sif::debug << "PtmeRateSetter::setRate: Unknown bit rate" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - return result; + return ptmeAxiConfig->writeCaduRateReg(rateVal); } diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index 14dfec4b..6b9d6c5a 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -3,36 +3,36 @@ #include "TxRateSetterIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/common/gpio/GpioIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "linux/obc/PtmeAxiConfig.h" +#include "linux/obc/PtmeConfig.h" +#include "fsfw/objectmanager/SystemObject.h" /** - * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in - * the programmable logic. + * @brief Class to set the downlink bit rate by writing to the AXI configuration interface of the + * PTME IP core. * - * @details The cadu_rate_switcher module sets the input rate to the syrlinks transceiver either - * to 2000 kHz (bitrateSel = 1) or 400 kHz (bitrate = 0). + * @details This is the bitrate of the CADU clock and not the downlink which has twice the bitrate + * of the CADU clock due to the convolutional code added by the s-Band transceiver. * * @author J. Meier */ -class PtmeRateSetter : public TxRateSetterIF { - public: - /** - * @brief Constructor - * - * @param bitrateSel GPIO ID of the GPIO connected to the bitrate_sel input of the - * cadu_rate_switcher. - * @param gpioif GPIO interface to drive the bitrateSel GPIO - */ - PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif); - virtual ~PtmeRateSetter(); +class PtmeRateSetter: public TxRateSetterIF, public SystemObject { +public: + /** + * @brief Constructor + * + * objectId Object id of system object + * ptmeAxiConfig Pointer to object providing access to PTME configuration registers. + */ + PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig); + virtual ~PtmeRateSetter(); - virtual ReturnValue_t setRate(BitRates rate); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t setRate(BitRates rate); - private: - gpioId_t bitrateSel = gpio::NO_GPIO; +private: - GpioIF* gpioif = nullptr; + PtmeAxiConfig* ptmeAxiConfig = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index 1eaded33..6090825f 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,7 +3,14 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ }; +enum BitRates : uint32_t { + RATE_2000KBPS, + RATE_1000KBPS, + RATE_500KBPS, + RATE_400KBPS, + RATE_200KBPS, + RATE_100KBPS +}; /** * @brief Abstract class for objects implementing the functionality to switch the diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index ba34d273..3747b42d 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -191,11 +191,11 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t const uint8_t* data, size_t size) { switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_400KHZ); + txRateSetterIF->setRate(BitRates::RATE_100KBPS); return EXECUTION_FINISHED; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + txRateSetterIF->setRate(BitRates::RATE_500KBPS); return EXECUTION_FINISHED; } case EN_TRANSMITTER: { diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 3090c24e..aedeccff 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -23,6 +23,9 @@ * @brief This class handles the data exchange with the CCSDS IP cores implemented in the * programmable logic of the Q7S. * + * @details After reboot default CADU bitrate is always set to 100 kbps (results in downlink rate + * of 200 kbps due to convolutional code added by syrlinks transceiver) + * * @author J. Meier */ class CCSDSHandler : public SystemObject, diff --git a/tmtc b/tmtc index 6f24d6a8..580ac8b2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6f24d6a83995ca7a895c17a77a00bceac4d7f141 +Subproject commit 580ac8b2d7e73aa860f3de55066187d7684d2d64 From 512d339803fbfe52b45faf3eac4b78f66a1529c9 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 24 Jan 2022 15:38:00 +0100 Subject: [PATCH 12/45] clang formatter setup eclipse --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 6ad16a87..7d27b092 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ 13. [Eclipse](#eclipse) 14. [Running the OBSW on a Raspberry Pi](#rpi) 15. [FSFW](#fsfw) +16. [Coding Style](#coding-style) # General information @@ -1151,3 +1152,15 @@ git merge upstream/master Alternatively, changes from other upstreams (forks) and branches can be merged like that in the same way. + +# Coding Style +* the formatting is based on the clang-format tools +## Setting up eclipse auto-fromatter with clang-format +1. Help → Install New Software → Add +2. In location insert the link http://www.cppstyle.com/luna +3. The software package CppStyle should now be available for installation +4. On windows download the clang-formatting tools from https://llvm.org/builds/. On linux clang-format can be installed with the package manager. +5. Navigate to Preferences → C/C++ → CppStyle +6. Insert the path to the clang-format executable +7. Under C/C++ → Code Style → Formatter, change the formatter to CppStyle (clang-format) +8. Code can now be formatted with the clang tool by using the key combination Ctrl + Shift + f \ No newline at end of file From a07468f7b710a626b4568d310027a83c28e813ed Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 24 Jan 2022 16:33:22 +0100 Subject: [PATCH 13/45] introduced uio mapper class --- bsp_q7s/boardconfig/busConf.h | 11 ++- bsp_q7s/core/InitMission.cpp | 2 + bsp_q7s/core/ObjectFactory.cpp | 24 +++--- linux/obc/PapbVcInterface.cpp | 137 +++++++++++++++++---------------- linux/obc/PapbVcInterface.h | 9 ++- linux/obc/Ptme.cpp | 7 +- linux/obc/Ptme.h | 2 +- linux/obc/PtmeAxiConfig.cpp | 22 ++---- linux/obc/PtmeAxiConfig.h | 6 +- linux/obc/VcInterfaceIF.h | 2 +- 10 files changed, 120 insertions(+), 102 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 5abd109b..3e8a4b49 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -17,7 +17,16 @@ static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; -static constexpr char UIO_PTME_CONFIG[] = "/dev/uio4"; +static constexpr char UIO_PTME[] = "/dev/uio1"; +static constexpr int MAP_ID_PTME_CONFIG = 3; + +namespace uiomapids { + static const int PTME_VC0 = 0; + static const int PTME_VC1 = 1; + static const int PTME_VC2 = 2; + static const int PTME_VC3 = 3; + static const int PTME_CONFIG = 4; +} namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 96a43a81..1828349b 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -115,12 +115,14 @@ void initmission::initTasks() { } #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ +#if OBSW_ADD_ACS_HANDLERS == 1 PeriodicTaskIF* acsCtrl = factory->createPeriodicTask( "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); result = acsCtrl->addComponent(objects::GPS_CONTROLLER); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("ACS_CTRL", objects::GPS_CONTROLLER); } +#endif /* OBSW_ADD_ACS_HANDLERS */ #if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6db63f30..a801852e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -928,14 +928,18 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookiePtmeIp); // Creating virtual channel interfaces - VcInterfaceIF* vc0 = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, - gpioIds::VC0_PAPB_EMPTY, PtmeConfig::VC0_OFFSETT); - VcInterfaceIF* vc1 = new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, - gpioIds::VC1_PAPB_EMPTY, PtmeConfig::VC1_OFFSETT); - VcInterfaceIF* vc2 = new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, - gpioIds::VC2_PAPB_EMPTY, PtmeConfig::VC2_OFFSETT); - VcInterfaceIF* vc3 = new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, - gpioIds::VC3_PAPB_EMPTY, PtmeConfig::VC3_OFFSETT); + VcInterfaceIF* vc0 = + new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, + gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC0); + VcInterfaceIF* vc1 = + new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, + gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC1); + VcInterfaceIF* vc2 = + new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, + gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC2); + VcInterfaceIF* vc3 = + new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, + gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC3); // Creating ptme object and adding virtual channel interfaces Ptme* ptme = new Ptme(objects::PTME); @@ -944,8 +948,8 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { ptme->addVcInterface(ccsds::VC2, vc2); ptme->addVcInterface(ccsds::VC3, vc3); - PtmeAxiConfig* ptmeAxiConfig = new PtmeAxiConfig(objects::PTME_AXI_CONFIG, - std::string(q7s::UIO_PTME_CONFIG)); + PtmeAxiConfig* ptmeAxiConfig = + new PtmeAxiConfig(objects::PTME_AXI_CONFIG, q7s::UIO_PTME, q7s::uiomapids::PTME_CONFIG); TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(objects::TX_RATE_SETTER, ptmeAxiConfig); CCSDSHandler* ccsdsHandler = new CCSDSHandler( objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF, diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index f144306c..50cee1d3 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,98 +1,101 @@ #include - +#include #include "fsfw/serviceinterface/ServiceInterface.h" PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, - gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) - : SystemObject(objectId), - gpioComIF(gpioComIF), - papbBusyId(papbBusyId), - papbEmptyId(papbEmptyId), - vcOffset(vcOffset) {} + gpioId_t papbBusyId, gpioId_t papbEmptyId, std::string uioFile, int mapNum) : + SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId(papbBusyId), papbEmptyId( + papbEmptyId), uioFile(uioFile), mapNum(mapNum) { +} -PapbVcInterface::~PapbVcInterface() {} +PapbVcInterface::~PapbVcInterface() { +} -void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { - vcBaseReg = ptmeBaseAddress + vcOffset; +ReturnValue_t PapbVcInterface::initialize() { + UioMapper uioMapper(uioFile, mapNum); + return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); } ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { - if (pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); - } - - for (size_t idx = 0; idx < size; idx++) { if (pollPapbBusySignal() == RETURN_OK) { - *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); - } else { - sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" - << std::endl; - return RETURN_FAILED; + startPacketTransfer(); } - } - - if (pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + for (size_t idx = 0; idx < size; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size + << " data" << std::endl; + return RETURN_FAILED; + } + } + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } +void PapbVcInterface::startPacketTransfer() { + *vcBaseReg = CONFIG_START; +} -void PapbVcInterface::endPacketTransfer() { *vcBaseReg = CONFIG_END; } +void PapbVcInterface::endPacketTransfer() { + *vcBaseReg = CONFIG_END; +} ReturnValue_t PapbVcInterface::pollPapbBusySignal() { - int papbBusyState = 0; - ReturnValue_t result = RETURN_OK; + int papbBusyState = 0; + ReturnValue_t result = RETURN_OK; - /** Check if PAPB interface is ready to receive data */ - result = gpioComIF->readGpio(papbBusyId, &papbBusyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; - return PAPB_BUSY; - } + /** Check if PAPB interface is ready to receive data */ + result = gpioComIF->readGpio(papbBusyId, &papbBusyState); + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void PapbVcInterface::isVcInterfaceBufferEmpty() { - ReturnValue_t result = RETURN_OK; - int papbEmptyState = 1; + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; - result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" - << std::endl; + if (result != RETURN_OK) { + sif::warning + << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + << std::endl; + return; + } + + if (papbEmptyState == 1) { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; + } return; - } - - if (papbEmptyState == 1) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; - } else { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; - } - return; } ReturnValue_t PapbVcInterface::sendTestFrame() { - /** Size of one complete transfer frame data field amounts to 1105 bytes */ - uint8_t testPacket[1105]; + /** Size of one complete transfer frame data field amounts to 1105 bytes */ + uint8_t testPacket[1105]; - /** Fill one test packet */ - for (int idx = 0; idx < 1105; idx++) { - testPacket[idx] = static_cast(idx & 0xFF); - } + /** Fill one test packet */ + for (int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } - ReturnValue_t result = write(testPacket, 1105); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = write(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index e7d03a70..465d1bf9 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -27,14 +27,16 @@ class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasRet * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the * VcInterface IP Core. The signal is high when there are no packets in the * external buffer memory (BRAM). + * @param uioFile UIO file providing access to the PAPB bus + * @param mapNum Map number of UIO map associated with this virtual channel */ PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, uint32_t vcOffset); + gpioId_t papbEmptyId, std::string uioFile, int mapNum); virtual ~PapbVcInterface(); ReturnValue_t write(const uint8_t* data, size_t size) override; - void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + ReturnValue_t initialize() override; private: static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; @@ -69,6 +71,9 @@ class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasRet /** High when external buffer memory of virtual channel is empty */ gpioId_t papbEmptyId = gpio::NO_GPIO; + std::string uioFile; + int mapNum = 0; + uint32_t* vcBaseReg = nullptr; uint32_t vcOffset = 0; diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 237e66ab..3c3403e0 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -1,7 +1,7 @@ #include #include #include - +#include #include "PtmeConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -20,7 +20,8 @@ ReturnValue_t Ptme::initialize() { * Map uio device in virtual address space * PROT_WRITE: Map uio device in writable only mode */ - ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, 0)); + ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, + 0 * getpagesize())); if (ptmeBaseAddress == MAP_FAILED) { sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; @@ -29,7 +30,7 @@ ReturnValue_t Ptme::initialize() { VcInterfaceMapIter iter; for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { - iter->second->setRegisterAddress(ptmeBaseAddress); + iter->second->initialize(); } return RETURN_OK; diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index d85885bc..4e4e6862 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -49,7 +49,7 @@ class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { static const int MAP_SIZE = 0x40000; #else /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + static const int MAP_SIZE = 0x1000; #endif /* BOARD_TE0720 == 1 */ /** diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp index 3ec45faa..fdf810de 100644 --- a/linux/obc/PtmeAxiConfig.cpp +++ b/linux/obc/PtmeAxiConfig.cpp @@ -1,9 +1,8 @@ -#include -#include #include "PtmeAxiConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw_hal/linux/uio/UioMapper.h" -PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio) : +PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) : SystemObject(objectId), configAxiUio(configAxiUio) { mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { @@ -15,18 +14,11 @@ PtmeAxiConfig::~PtmeAxiConfig() { } ReturnValue_t PtmeAxiConfig::initialize() { - int fd = open(configAxiUio.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - baseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, - fd, 0)); - - if (baseAddress == MAP_FAILED) { - sif::warning << "PtmeAxiConfig::initialize: Failed to map uio address" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + UioMapper uioMapper(configAxiUio, mapNum); + result = uioMapper.getMappedAdress(&baseAddress, UioMapper::Permissions::READ_WRITE); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; } return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/obc/PtmeAxiConfig.h b/linux/obc/PtmeAxiConfig.h index 2b3e9d26..1ea6c295 100644 --- a/linux/obc/PtmeAxiConfig.h +++ b/linux/obc/PtmeAxiConfig.h @@ -16,8 +16,9 @@ public: /** * @brief Constructor * @param configAxiUio Device file of UIO belonging to the AXI configuration interface. + * @param mapNum Number of map belonging to axi configuration interface. */ - PtmeAxiConfig(object_id_t objectId, std::string configAxiUio); + PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum); virtual ~PtmeAxiConfig(); virtual ReturnValue_t initialize() override; @@ -26,9 +27,10 @@ public: private: // Address of register storing the bitrate configuration parameter static const uint32_t CADU_BITRATE_REG = 0x0; - static const int MAP_SIZE = 0x1000; std::string configAxiUio; + std::string uioMap; + int mapNum = 0; MutexIF* mutex = nullptr; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeout = 20; diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index 0aa95691..45226e21 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -24,7 +24,7 @@ class VcInterfaceIF { */ virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; - virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; + virtual ReturnValue_t initialize() = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ From 7a57043df8ed8b3dd403483bf235a8bc0ed92dae Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Jan 2022 17:09:57 +0100 Subject: [PATCH 14/45] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 6f24d6a8..9ac5df0f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6f24d6a83995ca7a895c17a77a00bceac4d7f141 +Subproject commit 9ac5df0f027e9bfbc81c5dbda46d7d8ac1574782 From 93e84fde292899dec6f6242d7f7b63be915f00f8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 14:00:30 +0100 Subject: [PATCH 15/45] initialize map num --- linux/obc/PtmeAxiConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp index fdf810de..3750b831 100644 --- a/linux/obc/PtmeAxiConfig.cpp +++ b/linux/obc/PtmeAxiConfig.cpp @@ -3,7 +3,7 @@ #include "fsfw_hal/linux/uio/UioMapper.h" PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) : - SystemObject(objectId), configAxiUio(configAxiUio) { + SystemObject(objectId), configAxiUio(configAxiUio), mapNum(mapNum) { mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { sif::warning << "Failed to create mutex" << std::endl; From 38a1b496e7f75db3893247f43d6539034dd97779 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 14:33:06 +0100 Subject: [PATCH 16/45] papb interface no longer a system object --- bsp_q7s/core/ObjectFactory.cpp | 35 ++++----- common/config/commonObjects.h | 6 +- linux/obc/PapbVcInterface.cpp | 136 ++++++++++++++++----------------- linux/obc/PapbVcInterface.h | 9 +-- 4 files changed, 86 insertions(+), 100 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a801852e..a25eb290 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -893,35 +893,32 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookiePtmeIp = new GpioCookie; GpiodRegularByLineName* gpio = nullptr; std::stringstream consumer; - consumer << "0x" << std::hex << objects::PAPB_VC0; + consumer.str("PAPB VC0"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC0, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC0; + consumer.str("PAPB VC0"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC0, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC1; + consumer.str("PAPB VC 1"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC1, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC1, consumer.str()); + consumer.str("PAPB VC 1"); gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; + consumer.str("PAPB VC 2"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC2, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; + consumer.str("PAPB VC 2"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC2, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC3; + consumer.str("PAPB VC 3"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC3, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC3; + consumer.str("PAPB VC 3"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); @@ -929,17 +926,17 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { // Creating virtual channel interfaces VcInterfaceIF* vc0 = - new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, - gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC0); + new PapbVcInterface(gpioComIF, gpioIds::VC0_PAPB_BUSY, gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC0); VcInterfaceIF* vc1 = - new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, - gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC1); + new PapbVcInterface(gpioComIF, gpioIds::VC1_PAPB_BUSY, gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC1); VcInterfaceIF* vc2 = - new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, - gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC2); + new PapbVcInterface(gpioComIF, gpioIds::VC2_PAPB_BUSY, gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC2); VcInterfaceIF* vc3 = - new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, - gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC3); + new PapbVcInterface(gpioComIF, gpioIds::VC3_PAPB_BUSY, gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC3); // Creating ptme object and adding virtual channel interfaces Ptme* ptme = new Ptme(objects::PTME); diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index e29a2013..99096ba4 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -12,11 +12,7 @@ enum commonObjects: uint32_t { TMTC_POLLING_TASK = 0x50000400, FILE_SYSTEM_HANDLER = 0x50000500, PTME = 0x50000600, - PAPB_VC0 = 0x50000700, - PAPB_VC1 = 0x50000701, - PAPB_VC2 = 0x50000702, - PAPB_VC3 = 0x50000703, - PDEC_HANDLER = 0x50000704, + PDEC_HANDLER = 0x50000700, CCSDS_HANDLER = 0x50000800, /* 0x43 ('C') for Controllers */ diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 50cee1d3..45358ee1 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,101 +1,97 @@ -#include #include +#include #include "fsfw/serviceinterface/ServiceInterface.h" -PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, - gpioId_t papbBusyId, gpioId_t papbEmptyId, std::string uioFile, int mapNum) : - SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId(papbBusyId), papbEmptyId( - papbEmptyId), uioFile(uioFile), mapNum(mapNum) { -} +PapbVcInterface::PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, std::string uioFile, int mapNum) + : gpioComIF(gpioComIF), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId), + uioFile(uioFile), + mapNum(mapNum) {} -PapbVcInterface::~PapbVcInterface() { -} +PapbVcInterface::~PapbVcInterface() {} ReturnValue_t PapbVcInterface::initialize() { - UioMapper uioMapper(uioFile, mapNum); - return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); + UioMapper uioMapper(uioFile, mapNum); + return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); } ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } + for (size_t idx = 0; idx < size; idx++) { if (pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" + << std::endl; + return RETURN_FAILED; } - for (size_t idx = 0; idx < size; idx++) { - if (pollPapbBusySignal() == RETURN_OK) { - *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); - } else { - sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size - << " data" << std::endl; - return RETURN_FAILED; - } - } - if (pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + } + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void PapbVcInterface::startPacketTransfer() { - *vcBaseReg = CONFIG_START; -} +void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } -void PapbVcInterface::endPacketTransfer() { - *vcBaseReg = CONFIG_END; -} +void PapbVcInterface::endPacketTransfer() { *vcBaseReg = CONFIG_END; } ReturnValue_t PapbVcInterface::pollPapbBusySignal() { - int papbBusyState = 0; - ReturnValue_t result = RETURN_OK; + int papbBusyState = 0; + ReturnValue_t result = RETURN_OK; - /** Check if PAPB interface is ready to receive data */ - result = gpioComIF->readGpio(papbBusyId, &papbBusyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; - return PAPB_BUSY; - } + /** Check if PAPB interface is ready to receive data */ + result = gpioComIF->readGpio(papbBusyId, &papbBusyState); + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void PapbVcInterface::isVcInterfaceBufferEmpty() { - ReturnValue_t result = RETURN_OK; - int papbEmptyState = 1; + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; - result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); - if (result != RETURN_OK) { - sif::warning - << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; - } else { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t PapbVcInterface::sendTestFrame() { - /** Size of one complete transfer frame data field amounts to 1105 bytes */ - uint8_t testPacket[1105]; + /** Size of one complete transfer frame data field amounts to 1105 bytes */ + uint8_t testPacket[1105]; - /** Fill one test packet */ - for (int idx = 0; idx < 1105; idx++) { - testPacket[idx] = static_cast(idx & 0xFF); - } + /** Fill one test packet */ + for (int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } - ReturnValue_t result = write(testPacket, 1105); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = write(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index 465d1bf9..d4df659e 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -3,9 +3,7 @@ #include #include - #include "OBSWConfig.h" -#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "linux/obc/VcInterfaceIF.h" @@ -15,12 +13,11 @@ * * @author J. Meier */ -class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasReturnvaluesIF { +class PapbVcInterface : public VcInterfaceIF, public HasReturnvaluesIF { public: /** * @brief Constructor * - * @param objectId * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the * VcInterface IP Core. A low logic level indicates the VcInterface is not * ready to receive more data. @@ -30,8 +27,8 @@ class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasRet * @param uioFile UIO file providing access to the PAPB bus * @param mapNum Map number of UIO map associated with this virtual channel */ - PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, std::string uioFile, int mapNum); + PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, gpioId_t papbEmptyId, + std::string uioFile, int mapNum); virtual ~PapbVcInterface(); ReturnValue_t write(const uint8_t* data, size_t size) override; From 102385a70748a9b295eac00b0b14197b9ed5e342 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 18:55:52 +0100 Subject: [PATCH 17/45] introduced axi configuration interface for ptme ip core --- bsp_q7s/core/ObjectFactory.cpp | 3 +- common/config/commonClassIds.h | 1 + fsfw | 2 +- linux/obc/PdecHandler.cpp | 66 +++++----------------------------- linux/obc/PdecHandler.h | 19 ---------- linux/obc/PtmeRateSetter.cpp | 40 +++++++-------------- linux/obc/PtmeRateSetter.h | 38 ++++++++++++-------- linux/obc/TxRateSetterIF.h | 11 +----- mission/tmtc/CCSDSHandler.cpp | 20 ++++++++--- mission/tmtc/CCSDSHandler.h | 7 ++++ tmtc | 2 +- 11 files changed, 73 insertions(+), 136 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a25eb290..72627679 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -973,8 +973,7 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookiePdec); new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET, - std::string(q7s::UIO_PDEC_CONFIG_MEMORY), std::string(q7s::UIO_PDEC_RAM), - std::string(q7s::UIO_PDEC_REGISTERS)); + q7s::UIO_PDEC_CONFIG_MEMORY, q7s::UIO_PDEC_RAM, q7s::UIO_PDEC_REGISTERS); #if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index cd90272d..ab8e06d5 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -24,6 +24,7 @@ enum commonClassIds: uint8_t { PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC CCSDS_HANDLER, //CCSDS + RATE_SETTER, //RS ARCSEC_JSON_BASE, //JSONBASE NVM_PARAM_BASE, //NVMB COMMON_CLASS_ID_END // [EXPORT] : [END] diff --git a/fsfw b/fsfw index c1e0bcee..faf7da27 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 +Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636 diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index a5ee98d6..7dfcfd66 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,16 +1,14 @@ -#include "PdecHandler.h" - #include #include - #include #include - #include "OBSWConfig.h" +#include "PdecHandler.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" +#include "fsfw_hal/linux/uio/UioMapper.h" PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, @@ -44,17 +42,18 @@ ReturnValue_t PdecHandler::initialize() { ReturnValue_t result = RETURN_OK; - result = getRegisterAddress(); + UioMapper regMapper(uioRegisters); + result = regMapper.getMappedAdress(®isterBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - - result = getConfigMemoryBaseAddress(); + UioMapper configMemMapper(uioConfigMemory); + result = configMemMapper.getMappedAdress(&memoryBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - - result = getRamBaseAddress(); + UioMapper ramMapper(uioRamMemory); + result = ramMapper.getMappedAdress(&ramBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -76,55 +75,6 @@ ReturnValue_t PdecHandler::initialize() { MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->getId(); } -ReturnValue_t PdecHandler::getRegisterAddress() { - int fd = open(uioRegisters.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PdecHandler::getRegisterAddress: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } - - registerBaseAddress = static_cast( - mmap(NULL, REGISTER_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - - if (registerBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } - - return RETURN_OK; -} - -ReturnValue_t PdecHandler::getConfigMemoryBaseAddress() { - int fd = open(uioConfigMemory.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PdecHandler::getConfigMemoryBaseAddress: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } - - memoryBaseAddress = static_cast( - mmap(NULL, CONFIG_MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - - if (memoryBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } - - return RETURN_OK; -} - -ReturnValue_t PdecHandler::getRamBaseAddress() { - int fd = open(uioRamMemory.c_str(), O_RDWR); - - ramBaseAddress = - static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - - if (ramBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getRamBaseAddress: Failed to map RAM base address" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; -} - void PdecHandler::writePdecConfig() { PdecConfig pdecConfig; diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 2125800f..16a9abd4 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -231,25 +231,6 @@ class PdecHandler : public SystemObject, */ void readCommandQueue(void); - /** - * @brief Opens UIO device assigned to AXI to AHB converter giving access to the PDEC - * registers. The register base address will be mapped into the virtual address space. - */ - ReturnValue_t getRegisterAddress(); - - /** - * @brief Opens UIO device assigned to the base address of the PDEC memory space and maps the - * physical address into the virtual address space. - */ - ReturnValue_t getConfigMemoryBaseAddress(); - - /** - * @brief Opens UIO device assigned to the RAM section of the PDEC IP core memory map. - * - * @details A received TC segment will be written to this memory area. - */ - ReturnValue_t getRamBaseAddress(); - /** * @brief This functions writes the configuration parameters to the configuration * section of the PDEC. diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index 4a81c361..cace128b 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -8,34 +8,20 @@ PtmeRateSetter::PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfi PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::initialize() { - if (ptmeAxiConfig == nullptr) { - sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (ptmeAxiConfig == nullptr) { + sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - uint8_t rateVal = 0; - switch (rate) { - case RATE_2000KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 2000000 - 1); - break; - case RATE_1000KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 1000000 - 1); - break; - case RATE_500KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 500000 - 1); - break; - case RATE_200KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 200000 - 1); - break; - case RATE_100KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 100000 - 1); - break; - default: - sif::debug << "PtmeRateSetter::setRate: Unknown bit rate" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t PtmeRateSetter::setRate(uint32_t bitRate) { + if (bitRate == 0) { + return BAD_BIT_RATE; } - return ptmeAxiConfig->writeCaduRateReg(rateVal); + uint32_t rateVal = PtmeConfig::BIT_CLK_FREQ / bitRate - 1; + if (rateVal > 0xFF) { + return RATE_NOT_SUPPORTED; + } + return ptmeAxiConfig->writeCaduRateReg(static_cast(rateVal)); } diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index 6b9d6c5a..a5b1a8db 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -16,23 +16,33 @@ * * @author J. Meier */ -class PtmeRateSetter: public TxRateSetterIF, public SystemObject { -public: - /** - * @brief Constructor - * - * objectId Object id of system object - * ptmeAxiConfig Pointer to object providing access to PTME configuration registers. - */ - PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig); - virtual ~PtmeRateSetter(); +class PtmeRateSetter : public TxRateSetterIF, public SystemObject, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * objectId Object id of system object + * ptmeAxiConfig Pointer to object providing access to PTME configuration registers. + */ + PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig); + virtual ~PtmeRateSetter(); - virtual ReturnValue_t initialize() override; - virtual ReturnValue_t setRate(BitRates rate); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t setRate(uint32_t bitRate); -private: + private: - PtmeAxiConfig* ptmeAxiConfig = nullptr; + static const uint8_t INTERFACE_ID = CLASS_ID::RATE_SETTER; + + //! [EXPORT] : [COMMENT] The commanded rate is not supported by the current FPGA design + static const ReturnValue_t RATE_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Bad bitrate has been commanded (e.g. 0) + static const ReturnValue_t BAD_BIT_RATE = MAKE_RETURN_CODE(0xA1); + + // Bitrate register field is only 8 bit wide + static const uint32_t MAX_BITRATE = 0xFF; + + PtmeAxiConfig* ptmeAxiConfig = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index 6090825f..e8682551 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,15 +3,6 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { - RATE_2000KBPS, - RATE_1000KBPS, - RATE_500KBPS, - RATE_400KBPS, - RATE_200KBPS, - RATE_100KBPS -}; - /** * @brief Abstract class for objects implementing the functionality to switch the * downlink bit rate. @@ -23,7 +14,7 @@ class TxRateSetterIF { TxRateSetterIF(){}; virtual ~TxRateSetterIF(){}; - virtual ReturnValue_t setRate(BitRates bitRate) = 0; + virtual ReturnValue_t setRate(uint32_t bitRate) = 0; }; #endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 3747b42d..5c7e19ff 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -5,6 +5,7 @@ #include "fsfw/events/EventManagerIF.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" @@ -189,14 +190,21 @@ MessageQueueId_t CCSDSHandler::getRequestQueue() { ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_100KBPS); - return EXECUTION_FINISHED; + result = txRateSetterIF->setRate(RATE_100KBPS); + break; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_500KBPS); - return EXECUTION_FINISHED; + result = txRateSetterIF->setRate(RATE_500KBPS); + break; + } + case ARBITRARY_RATE: { + uint32_t bitrate = 0; + SerializeAdapter::deSerialize(&bitrate, &data, &size, SerializeIF::Endianness::BIG); + result = txRateSetterIF->setRate(bitrate); + break; } case EN_TRANSMITTER: { enableTransmit(); @@ -209,6 +217,10 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t default: return COMMAND_NOT_IMPLEMENTED; } + if (result != RETURN_OK) { + return result; + } + return EXECUTION_FINISHED; } void CCSDSHandler::checkEvents() { diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index aedeccff..d2782630 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -88,6 +88,13 @@ class CCSDSHandler : public SystemObject, static const ActionId_t SET_HIGH_RATE = 1; static const ActionId_t EN_TRANSMITTER = 2; static const ActionId_t DIS_TRANSMITTER = 3; + static const ActionId_t ARBITRARY_RATE = 4; + + // Syrlinks supports two bitrates (200 kbps and 1000 kbps) + // Due to convolutional code added by the syrlinks the input frequency must be half the + // target frequency + static const uint32_t RATE_100KBPS = 100000; + static const uint32_t RATE_500KBPS = 500000; //! [EXPORT] : [COMMENT] Received action message with unknown action id static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); diff --git a/tmtc b/tmtc index 580ac8b2..598635ee 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 580ac8b2d7e73aa860f3de55066187d7684d2d64 +Subproject commit 598635ee4fb1eb246980564ae9f3a0feb1f4da30 From 03707f2d6af817bc84c6b4efb5be3c8bd8ab77dd Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 19:05:42 +0100 Subject: [PATCH 18/45] removed unsued code --- linux/obc/Ptme.cpp | 19 ------------------- linux/obc/Ptme.h | 8 -------- 2 files changed, 27 deletions(-) diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 3c3403e0..8258fea0 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -10,29 +10,10 @@ Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {} Ptme::~Ptme() {} ReturnValue_t Ptme::initialize() { - int fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR); - if (fd < 1) { - sif::warning << "Ptme::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } - - /** - * Map uio device in virtual address space - * PROT_WRITE: Map uio device in writable only mode - */ - ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, - 0 * getpagesize())); - - if (ptmeBaseAddress == MAP_FAILED) { - sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } - VcInterfaceMapIter iter; for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { iter->second->initialize(); } - return RETURN_OK; } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 4e4e6862..cdb2d6c6 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -44,14 +44,6 @@ class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); -#if BOARD_TE0720 == 1 - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; -#else - /** Size of mapped address space */ - static const int MAP_SIZE = 0x1000; -#endif /* BOARD_TE0720 == 1 */ - /** * Configuration bits: * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 From 8ad2114d4bc1b899a40fdb5074c575eba183f3b9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 19:07:48 +0100 Subject: [PATCH 19/45] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index faf7da27..73608783 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636 +Subproject commit 7360878390004a5749362775206902e95bf721aa From 90b65d4d8aecd1ea4d68d558ef19ec0658ef75e9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 19:47:34 +0100 Subject: [PATCH 20/45] update fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 73608783..faf7da27 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 7360878390004a5749362775206902e95bf721aa +Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636 From 49bbfb7b7d001a27b82f12e9a28464fe7ead516e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 15:51:15 +0100 Subject: [PATCH 21/45] submodule updates --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index 9b770602..663810a2 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9b77060295c9c32ebfc2e7cf6517eb2e66216191 +Subproject commit 663810a29a3e78be1c1cb3bb8c362174823ac4f7 diff --git a/tmtc b/tmtc index 9ac5df0f..57398383 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9ac5df0f027e9bfbc81c5dbda46d7d8ac1574782 +Subproject commit 57398383ae81d7cc851fc36a6332d4946d3e17ce From 9998b54f89553468c98a980ff2ae32bb14c0372f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 16:35:42 +0100 Subject: [PATCH 22/45] hyperion handler working now --- bsp_q7s/core/InitMission.cpp | 4 +++- mission/devices/GPSHyperionHandler.cpp | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index c7ae801c..d0224d2c 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -208,7 +208,9 @@ void initmission::initTasks() { #endif /* OBSW_ADD_STAR_TRACKER == 1 */ #endif - //acsCtrl->startTask(); +#if OBSW_ADD_ACS_HANDLERS == 1 + acsCtrl->startTask(); +#endif sif::info << "Tasks started.." << std::endl; } diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 37b11bcb..2898dc92 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -98,33 +98,35 @@ void GPSHyperionHandler::readGpsDataFromGpsd() { // The data from the device will generally be read all at once. Therefore, we // can set all field here gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); + if(not gpsmm.is_open()) { + // Opening failed +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed" << std::endl; +#endif + } gps_data_t *gps; gps = gpsmm.read(); if (gps == nullptr) { - sif::warning << "Q7STestTask: Reading GPS data failed" << std::endl; + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" << std::endl; } PoolReadGuard pg(&gpsSet); if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { #if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" << std::endl; + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading dataset failed" << std::endl; #endif } - // Print messages - if ((gps->set & MODE_SET) != MODE_SET) { - // Could not even set mode - gpsSet.setValidity(false, true); - return; - } - if (gps->satellites_used > 0) { + // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix + gpsSet.fixMode.value = gps->fix.mode; + if(gps->fix.mode == 0 or gps->fix.mode == 1) { + gpsSet.setValidity(false, true); + } else if (gps->satellites_used > 0) { gpsSet.setValidity(true, true); } gpsSet.satInUse.value = gps->satellites_used; gpsSet.satInView.value = gps->satellites_visible; - // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix - gpsSet.fixMode = gps->fix.mode; if (std::isfinite(gps->fix.latitude)) { // Negative latitude -> South direction gpsSet.latitude.value = gps->fix.latitude; From bf73a2e442919efe74f9ae5633c12efedea50a97 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 17:52:28 +0100 Subject: [PATCH 23/45] increased the stack size for the GPS controller --- bsp_q7s/core/InitMission.cpp | 6 +++--- mission/devices/GPSHyperionHandler.cpp | 14 +++++--------- mission/devices/GPSHyperionHandler.h | 6 ++++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index d0224d2c..bf6bb2ca 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -117,7 +117,7 @@ void initmission::initTasks() { #if OBSW_ADD_ACS_HANDLERS == 1 PeriodicTaskIF* acsCtrl = factory->createPeriodicTask( - "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); + "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.4, missedDeadlineFunc); result = acsCtrl->addComponent(objects::GPS_CONTROLLER); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("ACS_CTRL", objects::GPS_CONTROLLER); @@ -136,10 +136,10 @@ void initmission::initTasks() { #if OBSW_ADD_STAR_TRACKER == 1 PeriodicTaskIF* strImgLoaderTask = factory->createPeriodicTask( - "FILE_SYSTEM_TASK", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); + "STR_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc); result = strImgLoaderTask->addComponent(objects::STR_HELPER); if (result != HasReturnvaluesIF::RETURN_OK) { - initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::STR_HELPER); + initmission::printAddObjectError("STR_HELPER", objects::STR_HELPER); } #endif /* OBSW_ADD_STAR_TRACKER == 1 */ diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 2898dc92..0517f296 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -4,11 +4,6 @@ #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" -#ifdef FSFW_OSAL_LINUX -#include -#include -#endif - #include #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 @@ -20,6 +15,7 @@ GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentI bool debugHyperionGps) : ExtendedControllerBase(objectId, objects::NO_OBJECT), gpsSet(this), + myGpsmm(GPSD_SHARED_MEMORY, nullptr), debugHyperionGps(debugHyperionGps) {} GPSHyperionHandler::~GPSHyperionHandler() {} @@ -97,15 +93,14 @@ ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) void GPSHyperionHandler::readGpsDataFromGpsd() { // The data from the device will generally be read all at once. Therefore, we // can set all field here - gpsmm gpsmm(GPSD_SHARED_MEMORY, 0); - if(not gpsmm.is_open()) { + if(not myGpsmm.is_open()) { // Opening failed #if FSFW_VERBOSE_LEVEL >= 1 sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed" << std::endl; #endif } - gps_data_t *gps; - gps = gpsmm.read(); + gps_data_t *gps = nullptr; + gps = myGpsmm.read(); if (gps == nullptr) { sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" << std::endl; } @@ -165,6 +160,7 @@ void GPSHyperionHandler::readGpsDataFromGpsd() { gpsSet.hours = timeOfDay.hour; gpsSet.minutes = timeOfDay.minute; gpsSet.seconds = timeOfDay.second; + debugHyperionGps = true; if (debugHyperionGps) { sif::info << "-- Hyperion GPS Data --" << std::endl; time_t timeRaw = gps->fix.time.tv_sec; diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index 026e1779..c5251794 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -6,6 +6,11 @@ #include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" +#ifdef FSFW_OSAL_LINUX +#include +#include +#endif + /** * @brief Device handler for the Hyperion HT-GPS200 device * @details @@ -38,6 +43,7 @@ class GPSHyperionHandler : public ExtendedControllerBase { private: GpsPrimaryDataset gpsSet; + gpsmm myGpsmm; bool debugHyperionGps = false; void readGpsDataFromGpsd(); From 5c535784e984fa3970180ce6bd2d02290202532a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 17:59:31 +0100 Subject: [PATCH 24/45] added back old GPS handler --- bsp_q7s/boardconfig/busConf.h | 12 +- bsp_q7s/core/ObjectFactory.cpp | 4 +- linux/obc/PapbVcInterface.cpp | 1 + linux/obc/PapbVcInterface.h | 1 + linux/obc/PdecHandler.cpp | 5 +- linux/obc/Ptme.cpp | 1 + linux/obc/PtmeAxiConfig.cpp | 57 ++-- linux/obc/PtmeAxiConfig.h | 44 +-- linux/obc/PtmeRateSetter.h | 3 +- mission/devices/CMakeLists.txt | 2 +- mission/devices/GPSHyperionHandler.cpp | 251 ++++++++++-------- mission/devices/GPSHyperionHandler.h | 55 ++-- .../devices/GPSHyperionLinuxController.cpp | 178 +++++++++++++ mission/devices/GPSHyperionLinuxController.h | 55 ++++ mission/devices/GomspaceDeviceHandler.cpp | 6 +- mission/devices/GomspaceDeviceHandler.h | 2 +- mission/devices/GyroADIS1650XHandler.cpp | 8 +- mission/devices/PDU1Handler.cpp | 5 +- mission/devices/PDU2Handler.cpp | 5 +- .../devicedefinitions/GPSDefinitions.h | 2 +- mission/tmtc/CCSDSHandler.cpp | 2 +- mission/tmtc/CCSDSHandler.h | 4 +- 22 files changed, 487 insertions(+), 216 deletions(-) create mode 100644 mission/devices/GPSHyperionLinuxController.cpp create mode 100644 mission/devices/GPSHyperionLinuxController.h diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 3e8a4b49..7f8453c9 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -21,12 +21,12 @@ static constexpr char UIO_PTME[] = "/dev/uio1"; static constexpr int MAP_ID_PTME_CONFIG = 3; namespace uiomapids { - static const int PTME_VC0 = 0; - static const int PTME_VC1 = 1; - static const int PTME_VC2 = 2; - static const int PTME_VC3 = 3; - static const int PTME_CONFIG = 4; -} +static const int PTME_VC0 = 0; +static const int PTME_VC1 = 1; +static const int PTME_VC2 = 2; +static const int PTME_VC3 = 3; +static const int PTME_CONFIG = 4; +} // namespace uiomapids namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 1b82d206..49c5f209 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -45,7 +45,7 @@ #include "linux/devices/devicedefinitions/SusDefinitions.h" #include "mission/core/GenericFactory.h" #include "mission/devices/ACUHandler.h" -#include "mission/devices/GPSHyperionHandler.h" +#include "mission/devices/GPSHyperionLinuxController.h" #include "mission/devices/GyroADIS1650XHandler.h" #include "mission/devices/HeaterHandler.h" #include "mission/devices/IMTQHandler.h" @@ -78,10 +78,10 @@ #include #include #include +#include #include #include #include -#include ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 45358ee1..5636975a 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,5 +1,6 @@ #include #include + #include "fsfw/serviceinterface/ServiceInterface.h" PapbVcInterface::PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index d4df659e..0d6382e3 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -3,6 +3,7 @@ #include #include + #include "OBSWConfig.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "linux/obc/VcInterfaceIF.h" diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index 7dfcfd66..f97c3965 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,9 +1,12 @@ +#include "PdecHandler.h" + #include #include + #include #include + #include "OBSWConfig.h" -#include "PdecHandler.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 8258fea0..68ba3924 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -2,6 +2,7 @@ #include #include #include + #include "PtmeConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp index 3750b831..0619ca38 100644 --- a/linux/obc/PtmeAxiConfig.cpp +++ b/linux/obc/PtmeAxiConfig.cpp @@ -1,41 +1,40 @@ #include "PtmeAxiConfig.h" + #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw_hal/linux/uio/UioMapper.h" -PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) : - SystemObject(objectId), configAxiUio(configAxiUio), mapNum(mapNum) { - mutex = MutexFactory::instance()->createMutex(); - if (mutex == nullptr) { - sif::warning << "Failed to create mutex" << std::endl; - } +PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) + : SystemObject(objectId), configAxiUio(configAxiUio), mapNum(mapNum) { + mutex = MutexFactory::instance()->createMutex(); + if (mutex == nullptr) { + sif::warning << "Failed to create mutex" << std::endl; + } } -PtmeAxiConfig::~PtmeAxiConfig() { -} +PtmeAxiConfig::~PtmeAxiConfig() {} ReturnValue_t PtmeAxiConfig::initialize() { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - UioMapper uioMapper(configAxiUio, mapNum); - result = uioMapper.getMappedAdress(&baseAddress, UioMapper::Permissions::READ_WRITE); - if (result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - return HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + UioMapper uioMapper(configAxiUio, mapNum); + result = uioMapper.getMappedAdress(&baseAddress, UioMapper::Permissions::READ_WRITE); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PtmeAxiConfig::writeCaduRateReg(uint8_t rateVal) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - result = mutex->lockMutex(timeoutType, mutexTimeout); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to lock mutex" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - *(baseAddress + CADU_BITRATE_REG) = static_cast(rateVal); - result = mutex->unlockMutex(); - if (result != HasReturnvaluesIF::RETURN_OK) { - sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to unlock mutex" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + result = mutex->lockMutex(timeoutType, mutexTimeout); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to lock mutex" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + *(baseAddress + CADU_BITRATE_REG) = static_cast(rateVal); + result = mutex->unlockMutex(); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to unlock mutex" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } - diff --git a/linux/obc/PtmeAxiConfig.h b/linux/obc/PtmeAxiConfig.h index 1ea6c295..4638d0c0 100644 --- a/linux/obc/PtmeAxiConfig.h +++ b/linux/obc/PtmeAxiConfig.h @@ -2,9 +2,10 @@ #define LINUX_OBC_PTMEAXICONFIG_H_ #include + #include "fsfw/ipc/MutexIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" /** * @brief Class providing low level access to the configuration interface of the PTME. @@ -12,31 +13,30 @@ * @author J. Meier */ class PtmeAxiConfig : public SystemObject { -public: - /** - * @brief Constructor - * @param configAxiUio Device file of UIO belonging to the AXI configuration interface. - * @param mapNum Number of map belonging to axi configuration interface. - */ - PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum); - virtual ~PtmeAxiConfig(); + public: + /** + * @brief Constructor + * @param configAxiUio Device file of UIO belonging to the AXI configuration interface. + * @param mapNum Number of map belonging to axi configuration interface. + */ + PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum); + virtual ~PtmeAxiConfig(); - virtual ReturnValue_t initialize() override; - ReturnValue_t writeCaduRateReg(uint8_t rateVal); + virtual ReturnValue_t initialize() override; + ReturnValue_t writeCaduRateReg(uint8_t rateVal); -private: - // Address of register storing the bitrate configuration parameter - static const uint32_t CADU_BITRATE_REG = 0x0; + private: + // Address of register storing the bitrate configuration parameter + static const uint32_t CADU_BITRATE_REG = 0x0; - std::string configAxiUio; - std::string uioMap; - int mapNum = 0; - MutexIF* mutex = nullptr; - MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; - uint32_t mutexTimeout = 20; - - uint32_t* baseAddress = nullptr; + std::string configAxiUio; + std::string uioMap; + int mapNum = 0; + MutexIF* mutex = nullptr; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t mutexTimeout = 20; + uint32_t* baseAddress = nullptr; }; #endif /* LINUX_OBC_PTMEAXICONFIG_H_ */ diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index a5b1a8db..44ac9b48 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -2,10 +2,10 @@ #define LINUX_OBC_PTMERATESETTER_H_ #include "TxRateSetterIF.h" +#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "linux/obc/PtmeAxiConfig.h" #include "linux/obc/PtmeConfig.h" -#include "fsfw/objectmanager/SystemObject.h" /** * @brief Class to set the downlink bit rate by writing to the AXI configuration interface of the @@ -31,7 +31,6 @@ class PtmeRateSetter : public TxRateSetterIF, public SystemObject, public HasRet virtual ReturnValue_t setRate(uint32_t bitRate); private: - static const uint8_t INTERFACE_ID = CLASS_ID::RATE_SETTER; //! [EXPORT] : [COMMENT] The commanded rate is not supported by the current FPGA design diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index ed811ed3..9491a3aa 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${TARGET_NAME} PUBLIC - GPSHyperionHandler.cpp + GPSHyperionLinuxController.cpp GomspaceDeviceHandler.cpp Tmp1075Handler.cpp PCDUHandler.cpp diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 0517f296..d6928bb5 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -3,41 +3,58 @@ #include "devicedefinitions/GPSDefinitions.h" #include "fsfw/datapool/PoolReadGuard.h" #include "fsfw/timemanager/Clock.h" - -#include +#include "lwgps/lwgps.h" #if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 #include #include #endif -GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t parentId, - bool debugHyperionGps) - : ExtendedControllerBase(objectId, objects::NO_OBJECT), +GPSHyperionHandler::GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, + CookieIF *comCookie, bool debugHyperionGps) + : DeviceHandlerBase(objectId, deviceCommunication, comCookie), gpsSet(this), - myGpsmm(GPSD_SHARED_MEMORY, nullptr), - debugHyperionGps(debugHyperionGps) {} + debugHyperionGps(debugHyperionGps) { + lwgps_init(&gpsData); +} GPSHyperionHandler::~GPSHyperionHandler() {} -void GPSHyperionHandler::performControlOperation() { -#ifdef FSFW_OSAL_LINUX - readGpsDataFromGpsd(); -#endif +void GPSHyperionHandler::doStartUp() { + if (internalState == InternalStates::NONE) { + commandExecuted = false; + internalState = InternalStates::WAIT_FIRST_MESSAGE; + } + + if (internalState == InternalStates::WAIT_FIRST_MESSAGE) { + if (commandExecuted) { + internalState = InternalStates::IDLE; + setMode(MODE_ON); + commandExecuted = false; + } + } } -LocalPoolDataSetBase *GPSHyperionHandler::getDataSetHandle(sid_t sid) { - return &gpsSet; +void GPSHyperionHandler::doShutDown() { + internalState = InternalStates::NONE; + commandExecuted = false; + setMode(_MODE_POWER_DOWN); } -ReturnValue_t GPSHyperionHandler::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { - return HasReturnvaluesIF::RETURN_OK; +ReturnValue_t GPSHyperionHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; } -ReturnValue_t GPSHyperionHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t *data, size_t size) { - switch (actionId) { +ReturnValue_t GPSHyperionHandler::buildNormalDeviceCommand(DeviceCommandId_t *id) { + return NOTHING_TO_SEND; +} + +ReturnValue_t GPSHyperionHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, + size_t commandDataLen) { + // By default, send nothing + rawPacketLen = 0; + switch (deviceCommand) { case (GpsHyperion::TRIGGER_RESET_PIN): { if (resetCallback != nullptr) { PoolReadGuard pg(&gpsSet); @@ -52,12 +69,97 @@ ReturnValue_t GPSHyperionHandler::executeAction(ActionId_t actionId, MessageQueu return HasReturnvaluesIF::RETURN_OK; } +ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, + DeviceCommandId_t *foundId, size_t *foundLen) { + // Pass data to GPS library + if (len > 0) { + // sif::debug << "GPSHandler::scanForReply: Received " << len << " bytes" << std::endl; + if (internalState == InternalStates::WAIT_FIRST_MESSAGE) { + // TODO: Check whether data is valid by checking whether NMEA start string is valid? + commandExecuted = true; + } + int result = lwgps_process(&gpsData, start, len); + if (result != 1) { + sif::warning << "GPSHandler::scanForReply: Issue processing GPS data with lwgps" << std::endl; + } else { + // The data from the device will generally be read all at once. Therefore, we + // can set all field here + PoolReadGuard pg(&gpsSet); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::scanForReply: Reading dataset failed" << std::endl; +#endif + } + // Print messages + if (gpsData.is_valid) { + // Set all entries valid now, set invalid on case basis if values are sanitized + gpsSet.setValidity(true, true); + } + // Negative latitude -> South direction + gpsSet.latitude.value = gpsData.latitude; + // Negative longitude -> West direction + gpsSet.longitude.value = gpsData.longitude; + if (gpsData.altitude > 600000.0 or gpsData.altitude < 400000.0) { + gpsSet.altitude.setValid(false); + } else { + gpsSet.altitude.setValid(true); + gpsSet.altitude.value = gpsData.altitude; + } + gpsSet.fixMode.value = gpsData.fix_mode; + gpsSet.satInUse.value = gpsData.sats_in_use; + Clock::TimeOfDay_t timeStruct = {}; + timeStruct.day = gpsData.date; + timeStruct.hour = gpsData.hours; + timeStruct.minute = gpsData.minutes; + timeStruct.month = gpsData.month; + timeStruct.second = gpsData.seconds; + // Convert two-digit year to full year (AD) + timeStruct.year = gpsData.year + 2000; + timeval timeval = {}; + Clock::convertTimeOfDayToTimeval(&timeStruct, &timeval); + gpsSet.year = timeStruct.year; + gpsSet.month = gpsData.month; + gpsSet.day = gpsData.date; + gpsSet.hours = gpsData.hours; + gpsSet.minutes = gpsData.minutes; + gpsSet.seconds = gpsData.seconds; + gpsSet.unixSeconds = timeval.tv_sec; + if (debugHyperionGps) { + sif::info << "GPS Data" << std::endl; + printf("Valid status: %d\n", gpsData.is_valid); + printf("Latitude: %f degrees\n", gpsData.latitude); + printf("Longitude: %f degrees\n", gpsData.longitude); + printf("Altitude: %f meters\n", gpsData.altitude); + } +#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 + std::string filename = "/mnt/sd0/gps_log.txt"; + std::ofstream gpsFile; + if (not std::filesystem::exists(filename)) { + gpsFile.open(filename, std::ofstream::out); + } + gpsFile.open(filename, std::ofstream::out | std::ofstream::app); + gpsFile.write("\n", 1); + gpsFile.write(reinterpret_cast(start), len); +#endif + } + *foundLen = len; + *foundId = GpsHyperion::GPS_REPLY; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t GPSHyperionHandler::interpretDeviceReply(DeviceCommandId_t id, + const uint8_t *packet) { + return HasReturnvaluesIF::RETURN_OK; +} + +uint32_t GPSHyperionHandler::getTransitionDelayMs(Mode_t from, Mode_t to) { return 5000; } + ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); - localDataPoolMap.emplace(GpsHyperion::SPEED, new PoolEntry({0.0})); localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); @@ -66,113 +168,36 @@ ReturnValue_t GPSHyperionHandler::initializeLocalDataPool(localpool::DataPool &l localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); - localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); return HasReturnvaluesIF::RETURN_OK; } +void GPSHyperionHandler::fillCommandAndReplyMap() { + // Reply length does not matter, packets should always arrive periodically + insertInReplyMap(GpsHyperion::GPS_REPLY, 4, &gpsSet, 0, true); + insertInCommandMap(GpsHyperion::TRIGGER_RESET_PIN); +} + +void GPSHyperionHandler::modeChanged() { internalState = InternalStates::NONE; } + void GPSHyperionHandler::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args) { this->resetCallback = resetCallback; resetCallbackArgs = args; } +void GPSHyperionHandler::debugInterface(uint8_t positionTracker, object_id_t objectId, + uint32_t parameter) {} + ReturnValue_t GPSHyperionHandler::initialize() { - ReturnValue_t result = ExtendedControllerBase::initialize(); + ReturnValue_t result = DeviceHandlerBase::initialize(); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } - return result; + // Enable reply immediately for now + return updatePeriodicReply(true, GpsHyperion::GPS_REPLY); } -ReturnValue_t GPSHyperionHandler::handleCommandMessage(CommandMessage *message) { - return ExtendedControllerBase::handleCommandMessage(message); +ReturnValue_t GPSHyperionHandler::acceptExternalDeviceCommands() { + return DeviceHandlerBase::acceptExternalDeviceCommands(); } - -#ifdef FSFW_OSAL_LINUX -void GPSHyperionHandler::readGpsDataFromGpsd() { - // The data from the device will generally be read all at once. Therefore, we - // can set all field here - if(not myGpsmm.is_open()) { - // Opening failed -#if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed" << std::endl; -#endif - } - gps_data_t *gps = nullptr; - gps = myGpsmm.read(); - if (gps == nullptr) { - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" << std::endl; - } - PoolReadGuard pg(&gpsSet); - if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { -#if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading dataset failed" << std::endl; -#endif - } - - // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix - gpsSet.fixMode.value = gps->fix.mode; - if(gps->fix.mode == 0 or gps->fix.mode == 1) { - gpsSet.setValidity(false, true); - } else if (gps->satellites_used > 0) { - gpsSet.setValidity(true, true); - } - - gpsSet.satInUse.value = gps->satellites_used; - gpsSet.satInView.value = gps->satellites_visible; - - if (std::isfinite(gps->fix.latitude)) { - // Negative latitude -> South direction - gpsSet.latitude.value = gps->fix.latitude; - } else { - gpsSet.latitude.setValid(false); - } - - if (std::isfinite(gps->fix.longitude)) { - // Negative longitude -> West direction - gpsSet.longitude.value = gps->fix.longitude; - } else { - gpsSet.longitude.setValid(false); - } - - if (std::isfinite(gps->fix.altitude)) { - gpsSet.altitude.value = gps->fix.altitude; - } else { - gpsSet.altitude.setValid(false); - } - - if (std::isfinite(gps->fix.speed)) { - gpsSet.speed.value = gps->fix.speed; - } else { - gpsSet.speed.setValid(false); - } - - gpsSet.unixSeconds.value = gps->fix.time.tv_sec; - timeval time = {}; - time.tv_sec = gpsSet.unixSeconds.value; - time.tv_usec = gps->fix.time.tv_nsec / 1000; - Clock::TimeOfDay_t timeOfDay = {}; - Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); - gpsSet.year = timeOfDay.year; - gpsSet.month = timeOfDay.month; - gpsSet.day = timeOfDay.day; - gpsSet.hours = timeOfDay.hour; - gpsSet.minutes = timeOfDay.minute; - gpsSet.seconds = timeOfDay.second; - debugHyperionGps = true; - if (debugHyperionGps) { - sif::info << "-- Hyperion GPS Data --" << std::endl; - time_t timeRaw = gps->fix.time.tv_sec; - std::tm *time = gmtime(&timeRaw); - std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl; - std::cout << "Visible satellites: " << gps->satellites_visible << std::endl; - std::cout << "Satellites used: " << gps->satellites_used << std::endl; - std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; - std::cout << "Latitude: " << gps->fix.latitude << std::endl; - std::cout << "Longitude: " << gps->fix.longitude << std::endl; - std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; - std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; - } -} -#endif diff --git a/mission/devices/GPSHyperionHandler.h b/mission/devices/GPSHyperionHandler.h index c5251794..b5734f23 100644 --- a/mission/devices/GPSHyperionHandler.h +++ b/mission/devices/GPSHyperionHandler.h @@ -3,13 +3,8 @@ #include "devicedefinitions/GPSDefinitions.h" #include "fsfw/FSFW.h" -#include "fsfw/controller/ExtendedControllerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" - -#ifdef FSFW_OSAL_LINUX -#include -#include -#endif +#include "lwgps/lwgps.h" /** * @brief Device handler for the Hyperion HT-GPS200 device @@ -17,36 +12,50 @@ * Flight manual: * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 */ -class GPSHyperionHandler : public ExtendedControllerBase { +class GPSHyperionHandler : public DeviceHandlerBase { public: - GPSHyperionHandler(object_id_t objectId, object_id_t parentId, bool debugHyperionGps = false); + GPSHyperionHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, + bool debugHyperionGps = false); virtual ~GPSHyperionHandler(); - using gpioResetFunction_t = ReturnValue_t (*)(void* args); + using gpioResetFunction_t = ReturnValue_t (*)(void *args); + + void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void *args); + ReturnValue_t acceptExternalDeviceCommands() override; - void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void* args); - ReturnValue_t handleCommandMessage(CommandMessage* message) override; - void performControlOperation() override; - LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; - ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t* msToReachTheMode) override; - ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) override; ReturnValue_t initialize() override; protected: gpioResetFunction_t resetCallback = nullptr; - void* resetCallbackArgs = nullptr; + void *resetCallbackArgs = nullptr; - ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) override; + enum class InternalStates { NONE, WAIT_FIRST_MESSAGE, IDLE }; + InternalStates internalState = InternalStates::NONE; + bool commandExecuted = false; + + /* DeviceHandlerBase overrides */ + ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + void doStartUp() override; + void doShutDown() override; + ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; + ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, + size_t commandDataLen) override; + ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, + size_t *foundLen) override; + ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + + void fillCommandAndReplyMap() override; + void modeChanged() override; + uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; + ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, + LocalDataPoolManager &poolManager) override; + virtual void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0, + uint32_t parameter = 0) override; private: + lwgps_t gpsData = {}; GpsPrimaryDataset gpsSet; - gpsmm myGpsmm; bool debugHyperionGps = false; - - void readGpsDataFromGpsd(); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/GPSHyperionLinuxController.cpp b/mission/devices/GPSHyperionLinuxController.cpp new file mode 100644 index 00000000..0955e1c7 --- /dev/null +++ b/mission/devices/GPSHyperionLinuxController.cpp @@ -0,0 +1,178 @@ +#include "GPSHyperionLinuxController.h" + +#include + +#include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/datapool/PoolReadGuard.h" +#include "fsfw/timemanager/Clock.h" + +#if FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV == 1 +#include +#include +#endif + +GPSHyperionLinuxController::GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, + bool debugHyperionGps) + : ExtendedControllerBase(objectId, objects::NO_OBJECT), + gpsSet(this), + myGpsmm(GPSD_SHARED_MEMORY, nullptr), + debugHyperionGps(debugHyperionGps) {} + +GPSHyperionLinuxController::~GPSHyperionLinuxController() {} + +void GPSHyperionLinuxController::performControlOperation() { +#ifdef FSFW_OSAL_LINUX + readGpsDataFromGpsd(); +#endif +} + +LocalPoolDataSetBase *GPSHyperionLinuxController::getDataSetHandle(sid_t sid) { return &gpsSet; } + +ReturnValue_t GPSHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t *msToReachTheMode) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t GPSHyperionLinuxController::executeAction(ActionId_t actionId, + MessageQueueId_t commandedBy, + const uint8_t *data, size_t size) { + switch (actionId) { + case (GpsHyperion::TRIGGER_RESET_PIN): { + if (resetCallback != nullptr) { + PoolReadGuard pg(&gpsSet); + // Set HK entries invalid + gpsSet.setValidity(false, true); + resetCallback(resetCallbackArgs); + return HasActionsIF::EXECUTION_FINISHED; + } + return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; + } + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool( + localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(GpsHyperion::ALTITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LONGITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::LATITUDE, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::SPEED, new PoolEntry({0.0})); + localDataPoolMap.emplace(GpsHyperion::YEAR, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MONTH, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::DAY, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::HOURS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::MINUTES, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::UNIX_SECONDS, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry()); + localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry()); + poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), true, 2.0, false); + return HasReturnvaluesIF::RETURN_OK; +} + +void GPSHyperionLinuxController::setResetPinTriggerFunction(gpioResetFunction_t resetCallback, + void *args) { + this->resetCallback = resetCallback; + resetCallbackArgs = args; +} + +ReturnValue_t GPSHyperionLinuxController::initialize() { + ReturnValue_t result = ExtendedControllerBase::initialize(); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return result; +} + +ReturnValue_t GPSHyperionLinuxController::handleCommandMessage(CommandMessage *message) { + return ExtendedControllerBase::handleCommandMessage(message); +} + +#ifdef FSFW_OSAL_LINUX +void GPSHyperionLinuxController::readGpsDataFromGpsd() { + // The data from the device will generally be read all at once. Therefore, we + // can set all field here + if (not myGpsmm.is_open()) { + // Opening failed +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM failed" << std::endl; +#endif + } + gps_data_t *gps = nullptr; + gps = myGpsmm.read(); + if (gps == nullptr) { + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed" << std::endl; + } + PoolReadGuard pg(&gpsSet); + if (pg.getReadResult() != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_VERBOSE_LEVEL >= 1 + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading dataset failed" << std::endl; +#endif + } + + // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix + gpsSet.fixMode.value = gps->fix.mode; + if (gps->fix.mode == 0 or gps->fix.mode == 1) { + gpsSet.setValidity(false, true); + } else if (gps->satellites_used > 0) { + gpsSet.setValidity(true, true); + } + + gpsSet.satInUse.value = gps->satellites_used; + gpsSet.satInView.value = gps->satellites_visible; + + if (std::isfinite(gps->fix.latitude)) { + // Negative latitude -> South direction + gpsSet.latitude.value = gps->fix.latitude; + } else { + gpsSet.latitude.setValid(false); + } + + if (std::isfinite(gps->fix.longitude)) { + // Negative longitude -> West direction + gpsSet.longitude.value = gps->fix.longitude; + } else { + gpsSet.longitude.setValid(false); + } + + if (std::isfinite(gps->fix.altitude)) { + gpsSet.altitude.value = gps->fix.altitude; + } else { + gpsSet.altitude.setValid(false); + } + + if (std::isfinite(gps->fix.speed)) { + gpsSet.speed.value = gps->fix.speed; + } else { + gpsSet.speed.setValid(false); + } + + gpsSet.unixSeconds.value = gps->fix.time.tv_sec; + timeval time = {}; + time.tv_sec = gpsSet.unixSeconds.value; + time.tv_usec = gps->fix.time.tv_nsec / 1000; + Clock::TimeOfDay_t timeOfDay = {}; + Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); + gpsSet.year = timeOfDay.year; + gpsSet.month = timeOfDay.month; + gpsSet.day = timeOfDay.day; + gpsSet.hours = timeOfDay.hour; + gpsSet.minutes = timeOfDay.minute; + gpsSet.seconds = timeOfDay.second; + debugHyperionGps = true; + if (debugHyperionGps) { + sif::info << "-- Hyperion GPS Data --" << std::endl; + time_t timeRaw = gps->fix.time.tv_sec; + std::tm *time = gmtime(&timeRaw); + std::cout << "Time: " << std::put_time(time, "%c %Z") << std::endl; + std::cout << "Visible satellites: " << gps->satellites_visible << std::endl; + std::cout << "Satellites used: " << gps->satellites_used << std::endl; + std::cout << "Fix (0:Not Seen|1:No Fix|2:2D|3:3D): " << gps->fix.mode << std::endl; + std::cout << "Latitude: " << gps->fix.latitude << std::endl; + std::cout << "Longitude: " << gps->fix.longitude << std::endl; + std::cout << "Altitude(MSL): " << gps->fix.altMSL << std::endl; + std::cout << "Speed(m/s): " << gps->fix.speed << std::endl; + } +} +#endif diff --git a/mission/devices/GPSHyperionLinuxController.h b/mission/devices/GPSHyperionLinuxController.h new file mode 100644 index 00000000..57da40e6 --- /dev/null +++ b/mission/devices/GPSHyperionLinuxController.h @@ -0,0 +1,55 @@ +#ifndef MISSION_DEVICES_GPSHYPERIONHANDLER_H_ +#define MISSION_DEVICES_GPSHYPERIONHANDLER_H_ + +#include "devicedefinitions/GPSDefinitions.h" +#include "fsfw/FSFW.h" +#include "fsfw/controller/ExtendedControllerBase.h" +#include "fsfw/devicehandlers/DeviceHandlerBase.h" + +#ifdef FSFW_OSAL_LINUX +#include +#include +#endif + +/** + * @brief Device handler for the Hyperion HT-GPS200 device + * @details + * Flight manual: + * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/Hyperion_HT-GPS200 + * This device handler can only be used on Linux system where the gpsd daemon with shared memory + * export is running. + */ +class GPSHyperionLinuxController : public ExtendedControllerBase { + public: + GPSHyperionLinuxController(object_id_t objectId, object_id_t parentId, + bool debugHyperionGps = false); + virtual ~GPSHyperionLinuxController(); + + using gpioResetFunction_t = ReturnValue_t (*)(void* args); + + void setResetPinTriggerFunction(gpioResetFunction_t resetCallback, void* args); + ReturnValue_t handleCommandMessage(CommandMessage* message) override; + void performControlOperation() override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, + uint32_t* msToReachTheMode) override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, + const uint8_t* data, size_t size) override; + ReturnValue_t initialize() override; + + protected: + gpioResetFunction_t resetCallback = nullptr; + void* resetCallbackArgs = nullptr; + + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; + + private: + GpsPrimaryDataset gpsSet; + gpsmm myGpsmm; + bool debugHyperionGps = false; + + void readGpsDataFromGpsd(); +}; + +#endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index ce86d13a..4cec651e 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -187,8 +187,8 @@ void GomspaceDeviceHandler::setNormalDatapoolEntriesInvalid() {} ReturnValue_t GomspaceDeviceHandler::generateSetParamCommand(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = setParamCacher.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::BIG); + ReturnValue_t result = + setParamCacher.deSerialize(&commandData, &commandDataLen, SerializeIF::Endianness::BIG); if (result != HasReturnvaluesIF::RETURN_OK) { sif::error << "GomspaceDeviceHandler: Failed to deserialize set parameter " "message" @@ -346,7 +346,7 @@ ReturnValue_t GomspaceDeviceHandler::childCommandHook(DeviceCommandId_t cmd, } ReturnValue_t GomspaceDeviceHandler::setParamCallback(SetParamMessageUnpacker& unpacker, - bool afterExecution) { + bool afterExecution) { return HasReturnvaluesIF::RETURN_OK; } diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index efe18ee5..3d50b27b 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -126,7 +126,7 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { * execution * @return */ - virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker& unpacker, bool afterExecution); + virtual ReturnValue_t setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution); /** * @brief Function to generate the command to get a parameter from a diff --git a/mission/devices/GyroADIS1650XHandler.cpp b/mission/devices/GyroADIS1650XHandler.cpp index 717a1bfd..0965e265 100644 --- a/mission/devices/GyroADIS1650XHandler.cpp +++ b/mission/devices/GyroADIS1650XHandler.cpp @@ -55,7 +55,7 @@ void GyroADIS1650XHandler::doStartUp() { } if (internalState == InternalState::IDLE) { - if(goToNormalMode) { + if (goToNormalMode) { setMode(MODE_NORMAL); } else { setMode(MODE_ON); @@ -211,7 +211,7 @@ ReturnValue_t GyroADIS1650XHandler::interpretDeviceReply(DeviceCommandId_t id, if (((adisType == ADIS1650X::Type::ADIS16507) and (readProdId != ADIS1650X::PROD_ID_16507)) or ((adisType == ADIS1650X::Type::ADIS16505) and (readProdId != ADIS1650X::PROD_ID_16505))) { #if OBSW_VERBOSE_LEVEL >= 1 - if(warningSwitch) { + if (warningSwitch) { sif::warning << "GyroADIS1650XHandler::interpretDeviceReply: Invalid product ID " << readProdId << std::endl; } @@ -327,9 +327,7 @@ ReturnValue_t GyroADIS1650XHandler::handleSensorData(const uint8_t *packet) { return HasReturnvaluesIF::RETURN_OK; } -uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - return 6000; -} +uint32_t GyroADIS1650XHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 6000; } void GyroADIS1650XHandler::prepareWriteCommand(uint8_t startReg, uint8_t valueOne, uint8_t valueTwo) { diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index d1276c7f..48b79551 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -73,10 +73,11 @@ void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, vo this->hookArgs = args; } -ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { +ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, + bool afterExecution) { using namespace PDU1; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; - if(not afterExecution) { + if (not afterExecution) { return HasReturnvaluesIF::RETURN_OK; } if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index 61e9bb6a..776cae58 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -427,10 +427,11 @@ void PDU2Handler::printHkTable() { << std::endl; } -ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { +ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, + bool afterExecution) { using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; - if(not afterExecution) { + if (not afterExecution) { return HasReturnvaluesIF::RETURN_OK; } if (channelSwitchHook != nullptr and unpacker.getParameterSize() == 1) { diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index ce58f680..5a565fea 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -55,7 +55,7 @@ class GpsPrimaryDataset : public StaticLocalDataSet<18> { lp_var_t(sid.objectId, GpsHyperion::UNIX_SECONDS, this); private: - friend class GPSHyperionHandler; + friend class GPSHyperionLinuxController; GpsPrimaryDataset(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, GpsHyperion::DATASET_ID) {} }; diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 5c7e19ff..bb31723b 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -218,7 +218,7 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t return COMMAND_NOT_IMPLEMENTED; } if (result != RETURN_OK) { - return result; + return result; } return EXECUTION_FINISHED; } diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index d2782630..95c22a78 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -103,8 +103,8 @@ class CCSDSHandler : public SystemObject, // syrlinks must not be transmitting more than 15 minutes (according to datasheet) static const uint32_t TRANSMITTER_TIMEOUT = 900000; // 900000 ms = 15 min #else - // Set to high value when not sending via syrlinks - static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day + // Set to high value when not sending via syrlinks + static const uint32_t TRANSMITTER_TIMEOUT = 86400000; // 1 day #endif /* OBSW_SYRLINKS_DOWNLINK == 0 */ static const bool UP = true; From e8cd2207cfe798c6ad46bc6a85b674b234efcbf1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Jan 2022 18:04:28 +0100 Subject: [PATCH 25/45] repoint fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 663810a2..cc7a3a5a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 663810a29a3e78be1c1cb3bb8c362174823ac4f7 +Subproject commit cc7a3a5a342aa274ba85805ebdfef65224bbe80c From b4505e53050662eaa602d8c1e7754941b882c9b5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 27 Jan 2022 12:06:09 +0100 Subject: [PATCH 26/45] update project file --- misc/eclipse/.cproject | 145 +++++++++++++++++++++++++++++++---------- 1 file changed, 112 insertions(+), 33 deletions(-) diff --git a/misc/eclipse/.cproject b/misc/eclipse/.cproject index 3bab5367..e2984ed8 100644 --- a/misc/eclipse/.cproject +++ b/misc/eclipse/.cproject @@ -19,10 +19,12 @@ - + @@ -31,6 +33,8 @@ @@ -38,6 +42,8 @@ @@ -79,6 +85,8 @@ @@ -87,6 +95,8 @@ @@ -94,6 +104,8 @@ @@ -137,6 +149,8 @@