run clang formatting script
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Jakob Meier 2022-03-27 13:07:18 +02:00
parent 3fe9599c48
commit 6d04c278c3
12 changed files with 1678 additions and 1693 deletions

View File

@ -3,8 +3,8 @@
#include "InitMission.h" #include "InitMission.h"
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "OBSWVersion.h" #include "OBSWVersion.h"
#include "fsfw/version.h"
#include "fsfw/tasks/TaskFactory.h" #include "fsfw/tasks/TaskFactory.h"
#include "fsfw/version.h"
/** /**
* @brief This is the main program entry point for the egse (raspberry pi 4) * @brief This is the main program entry point for the egse (raspberry pi 4)

View File

@ -19,12 +19,6 @@
#include "bsp_q7s/callbacks/pcduSwitchCb.h" #include "bsp_q7s/callbacks/pcduSwitchCb.h"
#include "bsp_q7s/callbacks/rwSpiCallback.h" #include "bsp_q7s/callbacks/rwSpiCallback.h"
#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/CoreController.h"
#include "linux/devices/ploc/PlocMemoryDumper.h"
#include "linux/devices/ploc/PlocSupervisorHandler.h"
#include "linux/devices/ploc/PlocUpdater.h"
#include "linux/devices/ploc/PlocMPSoCHandler.h"
#include "linux/devices/ploc/PlocMPSoCHelper.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "bsp_q7s/memory/FileSystemHandler.h" #include "bsp_q7s/memory/FileSystemHandler.h"
#include "busConf.h" #include "busConf.h"
#include "ccsdsConfig.h" #include "ccsdsConfig.h"
@ -38,7 +32,13 @@
#include "linux/csp/CspComIF.h" #include "linux/csp/CspComIF.h"
#include "linux/csp/CspCookie.h" #include "linux/csp/CspCookie.h"
#include "linux/devices/GPSHyperionLinuxController.h" #include "linux/devices/GPSHyperionLinuxController.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h" #include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
#include "linux/devices/ploc/PlocMPSoCHandler.h"
#include "linux/devices/ploc/PlocMPSoCHelper.h"
#include "linux/devices/ploc/PlocMemoryDumper.h"
#include "linux/devices/ploc/PlocSupervisorHandler.h"
#include "linux/devices/ploc/PlocUpdater.h"
#include "linux/devices/startracker/StarTrackerHandler.h" #include "linux/devices/startracker/StarTrackerHandler.h"
#include "linux/devices/startracker/StrHelper.h" #include "linux/devices/startracker/StrHelper.h"
#include "tmtc/apid.h" #include "tmtc/apid.h"
@ -181,13 +181,13 @@ void ObjectFactory::produce(void* args) {
#endif #endif
#if OBSW_ADD_PLOC_MPSOC == 1 #if OBSW_ADD_PLOC_MPSOC == 1
UartCookie* plocMpsocCookie = new UartCookie(objects::PLOC_MPSOC_HANDLER, UartCookie* plocMpsocCookie =
q7s::UART_PLOC_MPSOC_DEV, UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, new UartCookie(objects::PLOC_MPSOC_HANDLER, q7s::UART_PLOC_MPSOC_DEV,
mpsoc::MAX_REPLY_SIZE); UartModes::NON_CANONICAL, uart::PLOC_MPSOC_BAUD, mpsoc::MAX_REPLY_SIZE);
PlocMPSoCHelper* plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER); PlocMPSoCHelper* plocMpsocHelper = new PlocMPSoCHelper(objects::PLOC_MPSOC_HELPER);
PlocMPSoCHandler* plocMPSoCHandler = new PlocMPSoCHandler(objects::PLOC_MPSOC_HANDLER, PlocMPSoCHandler* plocMPSoCHandler = new PlocMPSoCHandler(
objects::UART_COM_IF, plocMpsocCookie, plocMpsocHelper); objects::PLOC_MPSOC_HANDLER, objects::UART_COM_IF, plocMpsocCookie, plocMpsocHelper);
plocMPSoCHandler->setStartUpImmediately(); plocMPSoCHandler->setStartUpImmediately();
#endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #endif /* OBSW_ADD_PLOC_MPSOC == 1 */
#if OBSW_ADD_PLOC_SUPERVISOR == 1 #if OBSW_ADD_PLOC_SUPERVISOR == 1

View File

@ -1,40 +1,40 @@
#include <fstream>
#include <filesystem>
#include "FilesystemHelper.h" #include "FilesystemHelper.h"
#include <filesystem>
#include <fstream>
#include "bsp_q7s/memory/SdCardManager.h" #include "bsp_q7s/memory/SdCardManager.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h" #include "fsfw/serviceinterface/ServiceInterfaceStream.h"
FilesystemHelper::FilesystemHelper() { FilesystemHelper::FilesystemHelper() {}
}
FilesystemHelper::~FilesystemHelper() { FilesystemHelper::~FilesystemHelper() {}
}
ReturnValue_t FilesystemHelper::checkPath(std::string path) { ReturnValue_t FilesystemHelper::checkPath(std::string path) {
SdCardManager* sdcMan = SdCardManager::instance(); SdCardManager* sdcMan = SdCardManager::instance();
if (sdcMan == nullptr) { if (sdcMan == nullptr) {
sif::warning << "FilesystemHelper::checkPath: Invalid SD card manager" << std::endl; sif::warning << "FilesystemHelper::checkPath: Invalid SD card manager" << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
}
if (path.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) ==
std::string(SdCardManager::SD_0_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 0 not mounted" << std::endl;
return SD_NOT_MOUNTED;
} }
if (path.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) } else if (path.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT)) ==
== std::string(SdCardManager::SD_0_MOUNT_POINT)) { std::string(SdCardManager::SD_1_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) { if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 0 not mounted" << std::endl; sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl;
return SD_NOT_MOUNTED; return SD_NOT_MOUNTED;
}
} else if (path.substr(0, sizeof(SdCardManager::SD_1_MOUNT_POINT))
== std::string(SdCardManager::SD_1_MOUNT_POINT)) {
if (!sdcMan->isSdCardMounted(sd::SLOT_0)) {
sif::warning << "FilesystemHelper::checkPath: SD card 1 not mounted" << std::endl;
return SD_NOT_MOUNTED;
}
} }
return RETURN_OK; }
return RETURN_OK;
} }
ReturnValue_t FilesystemHelper::fileExists(std::string file) { ReturnValue_t FilesystemHelper::fileExists(std::string file) {
if (not std::filesystem::exists(file)) { if (not std::filesystem::exists(file)) {
return FILE_NOT_EXISTS; return FILE_NOT_EXISTS;
} }
return RETURN_OK; return RETURN_OK;
} }

View File

@ -2,8 +2,9 @@
#define BSP_Q7S_MEMORY_FILESYSTEMHELPER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHELPER_H_
#include <string> #include <string>
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "commonClassIds.h" #include "commonClassIds.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
/** /**
* @brief This class implements often used functions concerning the file system management. * @brief This class implements often used functions concerning the file system management.
@ -11,39 +12,38 @@
* @author J. Meier * @author J. Meier
*/ */
class FilesystemHelper : public HasReturnvaluesIF { class FilesystemHelper : public HasReturnvaluesIF {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::FILE_SYSTEM_HELPER;
static const uint8_t INTERFACE_ID = CLASS_ID::FILE_SYSTEM_HELPER; //! [EXPORT] : [COMMENT] SD card specified with path string not mounted
static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Specified file does not exist on filesystem
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] SD card specified with path string not mounted FilesystemHelper();
static const ReturnValue_t SD_NOT_MOUNTED = MAKE_RETURN_CODE(0xA0); virtual ~FilesystemHelper();
//! [EXPORT] : [COMMENT] Specified file does not exist on filesystem
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xA1);
FilesystemHelper(); /**
virtual ~FilesystemHelper(); * @brief In case the path points to a directory on the sd card the function checks if the
* appropriate SD card is mounted.
*
* @param path Path to check
*
* @return RETURN_OK if path points to SD card and the appropriate SD card is mounted or if
* path does not point to SD card.
* Return error code if path points to SD card and the corresponding SD card is not
* mounted.
*/
static ReturnValue_t checkPath(std::string path);
/** /**
* @brief In case the path points to a directory on the sd card the function checks if the * @brief Checks if the file exists on the filesystem.
* appropriate SD card is mounted. *
* * param file File to check
* @param path Path to check *
* * @return RETURN_OK if fiel exists, otherwise return error code.
* @return RETURN_OK if path points to SD card and the appropriate SD card is mounted or if */
* path does not point to SD card. static ReturnValue_t fileExists(std::string file);
* Return error code if path points to SD card and the corresponding SD card is not
* mounted.
*/
static ReturnValue_t checkPath(std::string path);
/**
* @brief Checks if the file exists on the filesystem.
*
* param file File to check
*
* @return RETURN_OK if fiel exists, otherwise return error code.
*/
static ReturnValue_t fileExists(std::string file);
}; };
#endif /* BSP_Q7S_MEMORY_FILESYSTEMHELPER_H_ */ #endif /* BSP_Q7S_MEMORY_FILESYSTEMHELPER_H_ */

View File

@ -4,27 +4,27 @@
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
class MPSoCReturnValuesIF { class MPSoCReturnValuesIF {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF; static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF;
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC //! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC //! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC //! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC //! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Received command with invalid length //! [EXPORT] : [COMMENT] Received command with invalid length
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4); static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
//! [EXPORT] : [COMMENT] Filename of file in OBC filesystem is too long //! [EXPORT] : [COMMENT] Filename of file in OBC filesystem is too long
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5); static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command //! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6); static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] Filename of MPSoC file is to long (max. 256 bytes) //! [EXPORT] : [COMMENT] Filename of MPSoC file is to long (max. 256 bytes)
static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7); static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Command has invalid parameter //! [EXPORT] : [COMMENT] Command has invalid parameter
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8); static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8);
}; };
#endif /* MPSOC_RETURN_VALUES_IF_H_ */ #endif /* MPSOC_RETURN_VALUES_IF_H_ */

View File

@ -1,13 +1,12 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#include "MPSoCReturnValuesIF.h"
#include "OBSWConfig.h"
#include "eive/definitions.h"
#include "fsfw/globalfunctions/CRC.h" #include "fsfw/globalfunctions/CRC.h"
#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/tmtcpacket/SpacePacket.h" #include "fsfw/tmtcpacket/SpacePacket.h"
#include "eive/definitions.h"
#include "MPSoCReturnValuesIF.h"
#include "OBSWConfig.h"
namespace mpsoc { namespace mpsoc {

View File

@ -2,216 +2,214 @@
#define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ #define BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_
#include <string> #include <string>
#include "PlocMPSoCHelper.h"
#include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "fsfw_hal/linux/uart/UartComIF.h"
#include "PlocMPSoCHelper.h"
#include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h" #include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
/** /**
* @brief This is the device handler for the MPSoC of the payload computer. * @brief This is the device handler for the MPSoC of the payload computer.
* *
* @details The PLOC uses the space packet protocol for communication. On each command the PLOC * @details The PLOC uses the space packet protocol for communication. On each command the PLOC
* answers with at least one acknowledgment and one execution report. * answers with at least one acknowledgment and one execution report.
* Flight manual: https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_MPSoC * Flight manual:
* ICD: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_TAS-ILH-IRS/ICD-PLOC/ILH&fileid=1030263 * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/PLOC_MPSoC ICD:
* https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_TAS-ILH-IRS/ICD-PLOC/ILH&fileid=1030263
* *
* @note The sequence count in the space packets must be incremented with each received and sent * @note The sequence count in the space packets must be incremented with each received and sent
* packet. * packet.
* *
* @author J. Meier * @author J. Meier
*/ */
class PlocMPSoCHandler: public DeviceHandlerBase { class PlocMPSoCHandler : public DeviceHandlerBase {
public: public:
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie,
PlocMPSoCHelper* plocMPSoCHelper);
virtual ~PlocMPSoCHandler();
virtual ReturnValue_t initialize() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
void performOperationHook() override;
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie, protected:
PlocMPSoCHelper* plocMPSoCHelper); void doStartUp() override;
virtual ~PlocMPSoCHandler(); void doShutDown() override;
virtual ReturnValue_t initialize() override; ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
const uint8_t* data, size_t size) override; void fillCommandAndReplyMap() override;
void performOperationHook() override; ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
protected: private:
void doStartUp() override; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
private: //! [EXPORT] : [COMMENT] PLOC crc failure in telemetry packet
static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC receive acknowledgment failure report
//! P1: Command Id which leads the acknowledgment failure report
//! P2: The status field inserted by the MPSoC into the data field
static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC receive execution failure report
//! P1: Command Id which leads the execution failure report
//! P2: The status field inserted by the MPSoC into the data field
static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC reply has invalid crc
static const Event MPSOC_HANDLER_CRC_FAILURE = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Packet sequence count in received space packet does not match expected
//! count P1: Expected sequence count P2: Received sequence count
static const Event MPSOC_HANDLER_SEQ_CNT_MISMATCH = MAKE_EVENT(5, severity::LOW);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; //! [EXPORT] : [COMMENT] Received command has file string with invalid length
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xD0);
//! [EXPORT] : [COMMENT] PLOC crc failure in telemetry packet static const uint16_t APID_MASK = 0x7FF;
static const Event MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW); static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
//! [EXPORT] : [COMMENT] PLOC receive acknowledgment failure report static const uint8_t STATUS_OFFSET = 10;
//! P1: Command Id which leads the acknowledgment failure report
//! P2: The status field inserted by the MPSoC into the data field
static const Event ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC receive execution failure report
//! P1: Command Id which leads the execution failure report
//! P2: The status field inserted by the MPSoC into the data field
static const Event EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC reply has invalid crc
static const Event MPSOC_HANDLER_CRC_FAILURE = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Packet sequence count in received space packet does not match expected count
//! P1: Expected sequence count
//! P2: Received sequence count
static const Event MPSOC_HANDLER_SEQ_CNT_MISMATCH = MAKE_EVENT(5, severity::LOW);
//! [EXPORT] : [COMMENT] Received command has file string with invalid length MessageQueueIF* eventQueue = nullptr;
static const ReturnValue_t NAME_TOO_LONG = MAKE_RETURN_CODE(0xD0);
static const uint16_t APID_MASK = 0x7FF; SourceSequenceCounter sequenceCount;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
static const uint8_t STATUS_OFFSET = 10;
MessageQueueIF* eventQueue = nullptr; uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
SourceSequenceCounter sequenceCount; /**
* This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = mpsoc::NONE;
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE]; UartComIF* uartComIf = nullptr;
/** PlocMPSoCHelper* plocMPSoCHelper = nullptr;
* This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = mpsoc::NONE;
UartComIF* uartComIf = nullptr; // Used to block incoming commands when MPSoC helper class is currently executing a command
bool plocMPSoCHelperExecuting = false;
PlocMPSoCHelper* plocMPSoCHelper = nullptr; class TmMemReadReport {
public:
static const uint8_t FIX_SIZE = 14;
size_t rememberRequestedSize = 0;
};
// Used to block incoming commands when MPSoC helper class is currently executing a command TmMemReadReport tmMemReadReport;
bool plocMPSoCHelperExecuting = false;
class TmMemReadReport { /**
public: * @brief Handles events received from the PLOC MPSoC helper
static const uint8_t FIX_SIZE = 14; */
size_t rememberRequestedSize = 0; void handleEvent(EventMessage* eventMessage);
};
TmMemReadReport tmMemReadReport; ReturnValue_t prepareTcMemWrite(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcMemRead(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcFlashDelete(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcReplayStart(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcReplayStop();
ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcDownlinkPwrOff();
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
/** /**
* @brief Handles events received from the PLOC MPSoC helper * @brief Copies space packet into command buffer
*/ */
void handleEvent(EventMessage* eventMessage); void copyToCommandBuffer(mpsoc::TcBase* tc);
ReturnValue_t prepareTcMemWrite(const uint8_t * commandData, size_t commandDataLen); /**
ReturnValue_t prepareTcMemRead(const uint8_t * commandData, size_t commandDataLen); * @brief This function checks the crc of the received PLOC reply.
ReturnValue_t prepareTcFlashDelete(const uint8_t * commandData, size_t commandDataLen); *
ReturnValue_t prepareTcReplayStart(const uint8_t * commandData, size_t commandDataLen); * @param start Pointer to the first byte of the reply.
ReturnValue_t prepareTcReplayStop(); * @param foundLen Pointer to the length of the whole packet.
ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t * commandData, size_t commandDataLen); *
ReturnValue_t prepareTcDownlinkPwrOff(); * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t * commandData, size_t commandDataLen); */
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
/** /**
* @brief Copies space packet into command buffer * @brief This function handles the acknowledgment report.
*/ *
void copyToCommandBuffer(mpsoc::TcBase* tc); * @param data Pointer to the data holding the acknowledgment report.
*
* @return RETURN_OK if successful, otherwise an error code.
*/
ReturnValue_t handleAckReport(const uint8_t* data);
/** /**
* @brief This function checks the crc of the received PLOC reply. * @brief This function handles the data of a execution report.
* *
* @param start Pointer to the first byte of the reply. * @param data Pointer to the received data packet.
* @param foundLen Pointer to the length of the whole packet. *
* * @return RETURN_OK if successful, otherwise an error code.
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. */
*/ ReturnValue_t handleExecutionReport(const uint8_t* data);
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
/** /**
* @brief This function handles the acknowledgment report. * @brief This function handles the memory read report.
* *
* @param data Pointer to the data holding the acknowledgment report. * @param data Pointer to the data buffer holding the memory read report.
* *
* @return RETURN_OK if successful, otherwise an error code. * @return RETURN_OK if successful, otherwise an error code.
*/ */
ReturnValue_t handleAckReport(const uint8_t* data); ReturnValue_t handleMemoryReadReport(const uint8_t* data);
/** /**
* @brief This function handles the data of a execution report. * @brief Depending on the current active command, this function sets the reply id of the
* * next reply after a successful acknowledgment report has been received. This is
* @param data Pointer to the received data packet. * required by the function getNextReplyLength() to identify the length of the next
* * reply to read.
* @return RETURN_OK if successful, otherwise an error code. */
*/ void setNextReplyId();
ReturnValue_t handleExecutionReport(const uint8_t* data);
/** /**
* @brief This function handles the memory read report. * @brief This function handles action message replies in case the telemetry has been
* * requested by another object.
* @param data Pointer to the data buffer holding the memory read report. *
* * @param data Pointer to the telemetry data.
* @return RETURN_OK if successful, otherwise an error code. * @param dataSize Size of telemetry in bytes.
*/ * @param replyId Id of the reply. This will be added to the ActionMessage.
ReturnValue_t handleMemoryReadReport(const uint8_t* data); */
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/** /**
* @brief Depending on the current active command, this function sets the reply id of the * @brief In case an acknowledgment failure reply has been received this function disables
* next reply after a successful acknowledgment report has been received. This is * all previously enabled commands and resets the exepected replies variable of an
* required by the function getNextReplyLength() to identify the length of the next * active command.
* reply to read. */
*/ void disableAllReplies();
void setNextReplyId();
/** /**
* @brief This function handles action message replies in case the telemetry has been * @brief This function sends a failure report if the active action was commanded by an other
* requested by another object. * object.
* *
* @param data Pointer to the telemetry data. * @param replyId The id of the reply which signals a failure.
* @param dataSize Size of telemetry in bytes. * @param status A status byte which gives information about the failure type.
* @param replyId Id of the reply. This will be added to the ActionMessage. */
*/ void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/** /**
* @brief In case an acknowledgment failure reply has been received this function disables * @brief This function disables the execution report reply. Within this function also the
* all previously enabled commands and resets the exepected replies variable of an * the variable expectedReplies of an active command will be set to 0.
* active command. */
*/ void disableExeReportReply();
void disableAllReplies();
/** void printStatus(const uint8_t* data);
* @brief This function sends a failure report if the active action was commanded by an other
* object.
*
* @param replyId The id of the reply which signals a failure.
* @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
/** ReturnValue_t prepareTcModeReplay();
* @brief This function disables the execution report reply. Within this function also the
* the variable expectedReplies of an active command will be set to 0.
*/
void disableExeReportReply();
void printStatus(const uint8_t* data); uint16_t getStatus(const uint8_t* data);
ReturnValue_t prepareTcModeReplay();
uint16_t getStatus(const uint8_t* data);
}; };
#endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */ #endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */

View File

@ -67,7 +67,7 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
} }
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
result = FilesystemHelper::checkPath(obcFile); result = FilesystemHelper::checkPath(obcFile);
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -91,7 +91,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string
internalState = InternalState::FLASH_WRITE; internalState = InternalState::FLASH_WRITE;
result = resetHelper(); result = resetHelper();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
return result; return result;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,12 @@
#ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #ifndef MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
#define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ #define MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_
#include "OBSWConfig.h"
#include <linux/devices/devicedefinitions/PlocSupervisorDefinitions.h>
#include <bsp_q7s/memory/SdCardManager.h> #include <bsp_q7s/memory/SdCardManager.h>
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw_hal/linux/uart/UartComIF.h> #include <fsfw_hal/linux/uart/UartComIF.h>
#include <linux/devices/devicedefinitions/PlocSupervisorDefinitions.h>
#include "OBSWConfig.h"
/** /**
* @brief This is the device handler for the supervisor of the PLOC which is programmed by * @brief This is the device handler for the supervisor of the PLOC which is programmed by
@ -19,322 +20,325 @@
* Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960 * Arbeitsdaten/08_Used%20Components/PLOC&fileid=940960
* @author J. Meier * @author J. Meier
*/ */
class PlocSupervisorHandler: public DeviceHandlerBase { class PlocSupervisorHandler : public DeviceHandlerBase {
public: public:
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF* comCookie);
virtual ~PlocSupervisorHandler();
PlocSupervisorHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie); virtual ReturnValue_t initialize() override;
virtual ~PlocSupervisorHandler();
virtual ReturnValue_t initialize() override; protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
protected: private:
void doStartUp() override; static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData,size_t commandDataLen) override;
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize,
DeviceCommandId_t *foundId, size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
ReturnValue_t enableReplyInReplyMap(DeviceCommandMap::iterator command,
uint8_t expectedReplies = 1, bool useAlternateId = false,
DeviceCommandId_t alternateReplyID = 0) override;
size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
private: //! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Failed to read current system time
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4);
//! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0
//! for PS, 1 for PL and 2 for INT
static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid
//! timeouts must be in the range between 1000 and 360000 ms.
static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID
static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be
//! larger than 21.
static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA8);
//! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1
//! and 2.
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xA9);
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAA);
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe
//! commands are invalid (e.g. start address bigger than stop address)
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAB);
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with
//! other apid.
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAC);
//! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist
static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAD);
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have
//! been created with the reception of the first dump packet.
static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAE);
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_SUPERVISOR_HANDLER; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER;
//! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC //! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor //! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor //! [EXPORT] : [COMMENT] PLOC received execution failure report
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); static const Event SUPV_EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor //! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to read current system time
static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4);
//! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 for PS, 1 for PL and 2 for INT
static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid timeouts must be in the range between 1000 and 360000 ms.
static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID
static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be larger than 21.
static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA8);
//! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 and 2.
static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xA9);
//! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed.
static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAA);
//! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe commands are invalid (e.g. start address bigger than stop address)
static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAB);
//! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with other apid.
static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAC);
//! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist
static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAD);
//! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have been created with the reception of the first dump packet.
static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAE);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_SUPERVISOR_HANDLER; static const uint16_t APID_MASK = 0x7FF;
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF;
//! [EXPORT] : [COMMENT] PLOC supervisor crc failure in telemetry packet uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE];
static const Event SUPV_MEMORY_READ_RPT_CRC_FAILURE = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC supervisor received acknowledgment failure report
static const Event SUPV_ACK_FAILURE = MAKE_EVENT(2, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC received execution failure report
static const Event SUPV_EXE_FAILURE = MAKE_EVENT(3, severity::LOW);
//! [EXPORT] : [COMMENT] PLOC supervisor reply has invalid crc
static const Event SUPV_CRC_FAILURE_EVENT = MAKE_EVENT(4, severity::LOW);
static const uint16_t APID_MASK = 0x7FF; /**
static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; * This variable is used to store the id of the next reply to receive. This is necessary
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = PLOC_SPV::NONE;
uint8_t commandBuffer[PLOC_SPV::MAX_COMMAND_SIZE]; UartComIF* uartComIf = nullptr;
/** PLOC_SPV::HkSet hkset;
* This variable is used to store the id of the next reply to receive. This is necessary PLOC_SPV::BootStatusReport bootStatusReport;
* because the PLOC sends as reply to each command at least one acknowledgment and execution PLOC_SPV::LatchupStatusReport latchupStatusReport;
* report.
*/
DeviceCommandId_t nextReplyId = PLOC_SPV::NONE;
UartComIF* uartComIf = nullptr; /** Number of expected replies following the MRAM dump command */
uint32_t expectedMramDumpPackets = 0;
uint32_t receivedMramDumpPackets = 0;
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
bool packetInBuffer = false;
/** Points to the next free position in the space packet buffer */
uint16_t bufferTop = 0;
PLOC_SPV::HkSet hkset; /** This buffer is used to concatenate space packets received in two different read steps */
PLOC_SPV::BootStatusReport bootStatusReport; uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE];
PLOC_SPV::LatchupStatusReport latchupStatusReport;
/** Number of expected replies following the MRAM dump command */
uint32_t expectedMramDumpPackets = 0;
uint32_t receivedMramDumpPackets = 0;
/** Set to true as soon as a complete space packet is present in the spacePacketBuffer */
bool packetInBuffer = false;
/** Points to the next free position in the space packet buffer */
uint16_t bufferTop = 0;
/** This buffer is used to concatenate space packets received in two different read steps */
uint8_t spacePacketBuffer[PLOC_SPV::MAX_PACKET_SIZE];
#ifdef TE0720_1CFA #ifdef TE0720_1CFA
SdCardManager* sdcMan = nullptr; SdCardManager* sdcMan = nullptr;
#endif /* BOARD_TE0720 == 0 */ #endif /* BOARD_TE0720 == 0 */
/** Path to PLOC specific files on SD card */ /** Path to PLOC specific files on SD card */
std::string plocFilePath = "ploc"; std::string plocFilePath = "ploc";
std::string activeMramFile; std::string activeMramFile;
/** Setting this variable to true will enable direct downlink of MRAM packets */ /** Setting this variable to true will enable direct downlink of MRAM packets */
bool downlinkMramDump = false; bool downlinkMramDump = false;
/** /**
* @brief This function checks the crc of the received PLOC reply. * @brief This function checks the crc of the received PLOC reply.
* *
* @param start Pointer to the first byte of the reply. * @param start Pointer to the first byte of the reply.
* @param foundLen Pointer to the length of the whole packet. * @param foundLen Pointer to the length of the whole packet.
* *
* @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE. * @return RETURN_OK if CRC is ok, otherwise CRC_FAILURE.
*/ */
ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen); ReturnValue_t verifyPacket(const uint8_t* start, size_t foundLen);
/** /**
* @brief This function handles the acknowledgment report. * @brief This function handles the acknowledgment report.
* *
* @param data Pointer to the data holding the acknowledgment report. * @param data Pointer to the data holding the acknowledgment report.
* *
* @return RETURN_OK if successful, otherwise an error code. * @return RETURN_OK if successful, otherwise an error code.
*/ */
ReturnValue_t handleAckReport(const uint8_t* data); ReturnValue_t handleAckReport(const uint8_t* data);
/** /**
* @brief This function handles the data of a execution report. * @brief This function handles the data of a execution report.
* *
* @param data Pointer to the received data packet. * @param data Pointer to the received data packet.
* *
* @return RETURN_OK if successful, otherwise an error code. * @return RETURN_OK if successful, otherwise an error code.
*/ */
ReturnValue_t handleExecutionReport(const uint8_t* data); ReturnValue_t handleExecutionReport(const uint8_t* data);
/** /**
* @brief This function handles the housekeeping report. This means verifying the CRC of the * @brief This function handles the housekeeping report. This means verifying the CRC of the
* reply and filling the appropriate dataset. * reply and filling the appropriate dataset.
* *
* @param data Pointer to the data buffer holding the housekeeping read report. * @param data Pointer to the data buffer holding the housekeeping read report.
* *
* @return RETURN_OK if successful, otherwise an error code. * @return RETURN_OK if successful, otherwise an error code.
*/ */
ReturnValue_t handleHkReport(const uint8_t* data); ReturnValue_t handleHkReport(const uint8_t* data);
/** /**
* @brief This function calls the function to check the CRC of the received boot status report * @brief This function calls the function to check the CRC of the received boot status report
* and fills the associated dataset with the boot status information. * and fills the associated dataset with the boot status information.
*/ */
ReturnValue_t handleBootStatusReport(const uint8_t* data); ReturnValue_t handleBootStatusReport(const uint8_t* data);
ReturnValue_t handleLatchupStatusReport(const uint8_t* data); ReturnValue_t handleLatchupStatusReport(const uint8_t* data);
/** /**
* @brief Depending on the current active command, this function sets the reply id of the * @brief Depending on the current active command, this function sets the reply id of the
* next reply after a successful acknowledgment report has been received. This is * next reply after a successful acknowledgment report has been received. This is
* required by the function getNextReplyLength() to identify the length of the next * required by the function getNextReplyLength() to identify the length of the next
* reply to read. * reply to read.
*/ */
void setNextReplyId(); void setNextReplyId();
/** /**
* @brief This function handles action message replies in case the telemetry has been * @brief This function handles action message replies in case the telemetry has been
* requested by another object. * requested by another object.
* *
* @param data Pointer to the telemetry data. * @param data Pointer to the telemetry data.
* @param dataSize Size of telemetry in bytes. * @param dataSize Size of telemetry in bytes.
* @param replyId Id of the reply. This will be added to the ActionMessage. * @param replyId Id of the reply. This will be added to the ActionMessage.
*/ */
void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId);
/** /**
* @brief This function prepares a space packet which does not transport any data in the * @brief This function prepares a space packet which does not transport any data in the
* packet data field apart from the crc. * packet data field apart from the crc.
*/ */
void prepareEmptyCmd(uint16_t apid); void prepareEmptyCmd(uint16_t apid);
/** /**
* @brief This function initializes the space packet to select the boot image of the MPSoC. * @brief This function initializes the space packet to select the boot image of the MPSoC.
*/ */
void prepareSelBootImageCmd(const uint8_t * commandData); void prepareSelBootImageCmd(const uint8_t* commandData);
void prepareDisableHk(); void prepareDisableHk();
/** /**
* @brief This function fills the commandBuffer with the data to update the time of the * @brief This function fills the commandBuffer with the data to update the time of the
* PLOC supervisor. * PLOC supervisor.
*/ */
ReturnValue_t prepareSetTimeRefCmd(); ReturnValue_t prepareSetTimeRefCmd();
/** /**
* @brief This function fills the commandBuffer with the data to change the boot timeout * @brief This function fills the commandBuffer with the data to change the boot timeout
* value in the PLOC supervisor. * value in the PLOC supervisor.
*/ */
void prepareSetBootTimeoutCmd(const uint8_t * commandData); void prepareSetBootTimeoutCmd(const uint8_t* commandData);
void prepareRestartTriesCmd(const uint8_t * commandData); void prepareRestartTriesCmd(const uint8_t* commandData);
/** /**
* @brief This function fills the command buffer with the packet to enable or disable the * @brief This function fills the command buffer with the packet to enable or disable the
* watchdogs on the PLOC. * watchdogs on the PLOC.
*/ */
void prepareWatchdogsEnableCmd(const uint8_t * commandData); void prepareWatchdogsEnableCmd(const uint8_t* commandData);
/** /**
* @brief This function fills the command buffer with the packet to set the watchdog timer * @brief This function fills the command buffer with the packet to set the watchdog timer
* of one of the three watchdogs (PS, PL, INT). * of one of the three watchdogs (PS, PL, INT).
*/ */
ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t * commandData); ReturnValue_t prepareWatchdogsConfigTimeoutCmd(const uint8_t* commandData);
ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData, ReturnValue_t prepareLatchupConfigCmd(const uint8_t* commandData,
DeviceCommandId_t deviceCommand); DeviceCommandId_t deviceCommand);
ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData); ReturnValue_t prepareAutoCalibrateAlertCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData); ReturnValue_t prepareSetAlertLimitCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData); ReturnValue_t prepareSetAlertIrqFilterCmd(const uint8_t* commandData);
ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData); ReturnValue_t prepareSetAdcSweetPeriodCmd(const uint8_t* commandData);
void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData); void prepareSetAdcEnabledChannelsCmd(const uint8_t* commandData);
void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData); void prepareSetAdcWindowAndStrideCmd(const uint8_t* commandData);
void prepareSetAdcThresholdCmd(const uint8_t* commandData); void prepareSetAdcThresholdCmd(const uint8_t* commandData);
void prepareEnableNvmsCmd(const uint8_t* commandData); void prepareEnableNvmsCmd(const uint8_t* commandData);
void prepareSelectNvmCmd(const uint8_t* commandData); void prepareSelectNvmCmd(const uint8_t* commandData);
ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData); ReturnValue_t prepareRunAutoEmTest(const uint8_t* commandData);
ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData); ReturnValue_t prepareWipeMramCmd(const uint8_t* commandData);
ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData); ReturnValue_t prepareDumpMramCmd(const uint8_t* commandData);
void preparePrintCpuStatsCmd(const uint8_t* commandData); void preparePrintCpuStatsCmd(const uint8_t* commandData);
void prepareSetDbgVerbosityCmd(const uint8_t* commandData); void prepareSetDbgVerbosityCmd(const uint8_t* commandData);
void prepareSetGpioCmd(const uint8_t* commandData); void prepareSetGpioCmd(const uint8_t* commandData);
void prepareReadGpioCmd(const uint8_t* commandData); void prepareReadGpioCmd(const uint8_t* commandData);
/**
* @brief Copies the content of a space packet to the command buffer.
*/
void packetToOutBuffer(uint8_t* packetData, size_t fullSize);
/** /**
* @brief Copies the content of a space packet to the command buffer. * @brief In case an acknowledgment failure reply has been received this function disables
*/ * all previously enabled commands and resets the exepected replies variable of an
void packetToOutBuffer(uint8_t* packetData, size_t fullSize); * active command.
*/
void disableAllReplies();
/** /**
* @brief In case an acknowledgment failure reply has been received this function disables * @brief This function sends a failure report if the active action was commanded by an other
* all previously enabled commands and resets the exepected replies variable of an * object.
* active command. *
*/ * @param replyId The id of the reply which signals a failure.
void disableAllReplies(); * @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
/** /**
* @brief This function sends a failure report if the active action was commanded by an other * @brief This function disables the execution report reply. Within this function also the
* object. * the variable expectedReplies of an active command will be set to 0.
* */
* @param replyId The id of the reply which signals a failure. void disableExeReportReply();
* @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
/** /**
* @brief This function disables the execution report reply. Within this function also the * @brief Function is called in scanForReply and fills the spacePacketBuffer with the read
* the variable expectedReplies of an active command will be set to 0. * data until a full packet has been received.
*/ */
void disableExeReportReply(); ReturnValue_t parseMramPackets(const uint8_t* packet, size_t remainingSize, size_t* foundlen);
/** /**
* @brief Function is called in scanForReply and fills the spacePacketBuffer with the read * @brief This function generates the Service 8 packets for the MRAM dump data.
* data until a full packet has been received. */
*/ ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id);
ReturnValue_t parseMramPackets(const uint8_t *packet, size_t remainingSize, size_t* foundlen);
/** /**
* @brief This function generates the Service 8 packets for the MRAM dump data. * @brief With this function the number of expected replies following an MRAM dump command
*/ * will be increased. This is necessary to release the command in case not all replies
ReturnValue_t handleMramDumpPacket(DeviceCommandId_t id); * have been received.
*/
void increaseExpectedMramReplies(DeviceCommandId_t id);
/** /**
* @brief With this function the number of expected replies following an MRAM dump command * @brief Function checks if the packet written to the space packet buffer is really a
* will be increased. This is necessary to release the command in case not all replies * MRAM dump packet.
* have been received. */
*/ ReturnValue_t checkMramPacketApid();
void increaseExpectedMramReplies(DeviceCommandId_t id);
/** /**
* @brief Function checks if the packet written to the space packet buffer is really a * @brief Writes the data of the MRAM dump to a file. The file will be created when receiving
* MRAM dump packet. * the first packet.
*/ */
ReturnValue_t checkMramPacketApid(); ReturnValue_t handleMramDumpFile(DeviceCommandId_t id);
/** /**
* @brief Writes the data of the MRAM dump to a file. The file will be created when receiving * @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer.
* the first packet. *
*/ * @param spacePacket Pointer to the buffer holding the space packet.
ReturnValue_t handleMramDumpFile(DeviceCommandId_t id); *
* @return The value stored in the length field of the data field.
*/
uint16_t readSpacePacketLength(uint8_t* spacePacket);
/** /**
* @brief Extracts the length field of a spacePacket referenced by the spacePacket pointer. * @brief Extracts the sequence flags from a space packet referenced by the spacePacket
* * pointer.
* @param spacePacket Pointer to the buffer holding the space packet. *
* * @param spacePacket Pointer to the buffer holding the space packet.
* @return The value stored in the length field of the data field. *
*/ * @return uint8_t where the two least significant bits hold the sequence flags.
uint16_t readSpacePacketLength(uint8_t* spacePacket); */
uint8_t readSequenceFlags(uint8_t* spacePacket);
/** ReturnValue_t createMramDumpFile();
* @brief Extracts the sequence flags from a space packet referenced by the spacePacket ReturnValue_t getTimeStampString(std::string& timeStamp);
* pointer.
*
* @param spacePacket Pointer to the buffer holding the space packet.
*
* @return uint8_t where the two least significant bits hold the sequence flags.
*/
uint8_t readSequenceFlags(uint8_t* spacePacket);
ReturnValue_t createMramDumpFile();
ReturnValue_t getTimeStampString(std::string& timeStamp);
}; };
#endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */

View File

@ -1,11 +1,10 @@
#ifndef MISSION_DEVICES_PLOCUPDATER_H_ #ifndef MISSION_DEVICES_PLOCUPDATER_H_
#define MISSION_DEVICES_PLOCUPDATER_H_ #define MISSION_DEVICES_PLOCUPDATER_H_
#include "OBSWConfig.h"
#include <linux/devices/devicedefinitions/PlocSupervisorDefinitions.h> #include <linux/devices/devicedefinitions/PlocSupervisorDefinitions.h>
#include "fsfw/action/CommandActionHelper.h"
#include "OBSWConfig.h"
#include "bsp_q7s/memory/SdCardManager.h" #include "bsp_q7s/memory/SdCardManager.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
#include "eive/definitions.h" #include "eive/definitions.h"
#include "fsfw/action/ActionHelper.h" #include "fsfw/action/ActionHelper.h"
#include "fsfw/action/CommandActionHelper.h" #include "fsfw/action/CommandActionHelper.h"
@ -15,6 +14,7 @@
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcpacket/SpacePacket.h" #include "fsfw/tmtcpacket/SpacePacket.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
#include "linux/fsfwconfig/objects/systemObjectList.h" #include "linux/fsfwconfig/objects/systemObjectList.h"
/** /**

View File

@ -112,7 +112,7 @@ void ObjectFactory::produceGenericObjects() {
sif::info << "Created TCP server for TMTC commanding with listener port " sif::info << "Created TCP server for TMTC commanding with listener port "
<< tcpServer->getTcpPort() << std::endl; << tcpServer->getTcpPort() << std::endl;
#if TCP_SERVER_WIRETAPPING == 1 #if TCP_SERVER_WIRETAPPING == 1
tcpServer->enableWiretapping(true); tcpServer->enableWiretapping(true);
#endif /* TCP_SERVER_WIRETAPPING == 1 */ #endif /* TCP_SERVER_WIRETAPPING == 1 */
#endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */ #endif /* OBSW_USE_TMTC_TCP_BRIDGE == 0 */
tmtcBridge->setMaxNumberOfPacketsStored(70); tmtcBridge->setMaxNumberOfPacketsStored(70);